<!DOCTYPE html>


<html lang="en">
  

    <head>
      <meta charset="utf-8" />
        
      <meta
        name="viewport"
        content="width=device-width, initial-scale=1, maximum-scale=1"
      />
      <title> 朝花夕拾</title>
  <meta name="generator" content="hexo-theme-ayer">
      
      <link rel="shortcut icon" href="/ww.ico" />
       
<link rel="stylesheet" href="/dist/main.css">

      
<link rel="stylesheet" href="/css/fonts/remixicon.css">

      
<link rel="stylesheet" href="/css/custom.css">
 
      <script src="https://cdn.staticfile.org/pace/1.2.4/pace.min.js"></script>
       
 

      <link
        rel="stylesheet"
        href="https://cdn.jsdelivr.net/npm/@sweetalert2/theme-bulma@5.0.1/bulma.min.css"
      />
      <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11.0.19/dist/sweetalert2.min.js"></script>

      <!-- mermaid -->
      
      <style>
        .swal2-styled.swal2-confirm {
          font-size: 1.6rem;
        }
      </style>
    </head>
  </html>
</html>


<body>
  <div id="app">
    
      
    <main class="content on">
      
<section class="cover">
    
  <div class="cover-frame">
    <div class="bg-box">
      <img src="/images/cover8.jpg" alt="image frame" />
    </div>
    <div class="cover-inner text-center text-white">
      <h1><a href="/">朝花夕拾</a></h1>
      <div id="subtitle-box">
        
        <span id="subtitle"></span>
        
      </div>
      <div>
        
      </div>
    </div>
  </div>
  <div class="cover-learn-more">
    <a href="javascript:void(0)" class="anchor"><i class="ri-arrow-down-line"></i></a>
  </div>
</section>



<script src="https://cdn.staticfile.org/typed.js/2.0.12/typed.min.js"></script>


<!-- Subtitle -->

  <script>
    try {
      var typed = new Typed("#subtitle", {
        strings: ['', '', ''],
        startDelay: 0,
        typeSpeed: 200,
        loop: true,
        backSpeed: 100,
        showCursor: true
      });
    } catch (err) {
      console.log(err)
    }
  </script>
  
<div id="main">
  <section class="outer">
  
  
  

<div class="notice" style="margin-top:50px">
    <i class="ri-heart-fill"></i>
    <div class="notice-content" id="broad"></div>
</div>
<script type="text/javascript">
    fetch('https://v1.hitokoto.cn')
        .then(response => response.json())
        .then(data => {
            document.getElementById("broad").innerHTML = data.hitokoto;
        })
        .catch(console.error)
</script>

<style>
    .notice {
        padding: 20px;
        border: 1px dashed #e6e6e6;
        color: #969696;
        position: relative;
        display: inline-block;
        width: 100%;
        background: #fbfbfb50;
        border-radius: 10px;
    }

    .notice i {
        float: left;
        color: #999;
        font-size: 16px;
        padding-right: 10px;
        vertical-align: middle;
        margin-top: -2px;
    }

    .notice-content {
        display: initial;
        vertical-align: middle;
    }
</style>
  
  <article class="articles">
    
    
    
    
    <article
  id="post-GBase8s表DML逻辑日志观察-md"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2023/10/01/GBase8s%E8%A1%A8DML%E9%80%BB%E8%BE%91%E6%97%A5%E5%BF%97%E8%A7%82%E5%AF%9F-md/"
    >GBase8s表DML逻辑日志观察.md</a> 
</h2>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2023/10/01/GBase8s%E8%A1%A8DML%E9%80%BB%E8%BE%91%E6%97%A5%E5%BF%97%E8%A7%82%E5%AF%9F-md/" class="article-date">
  <time datetime="2023-10-01T05:19:56.000Z" itemprop="datePublished">2023-10-01</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/GBase8s/">GBase8s</a>
  </div>
   
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <h1 id="表DML逻辑日志观察"><a href="#表DML逻辑日志观察" class="headerlink" title="表DML逻辑日志观察"></a>表DML逻辑日志观察</h1><h2 id="测试表："><a href="#测试表：" class="headerlink" title="测试表："></a>测试表：</h2><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">drop</span> <span class="keyword">table</span> if <span class="keyword">exists</span> tt;</span><br><span class="line"><span class="keyword">create</span> <span class="keyword">table</span> tt (id <span class="type">int</span>, c1 <span class="type">char</span>(<span class="number">3</span>),c2 <span class="type">char</span>(<span class="number">9</span>),c3 <span class="type">varchar</span>(<span class="number">4</span>), c4 lvarchar(<span class="number">4</span>));</span><br></pre></td></tr></table></figure>

<h2 id="insert测试："><a href="#insert测试：" class="headerlink" title="insert测试："></a>insert测试：</h2><h3 id="插入5条记录："><a href="#插入5条记录：" class="headerlink" title="插入5条记录："></a>插入5条记录：</h3><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">insert</span> <span class="keyword">into</span> tt <span class="keyword">values</span>(<span class="number">0</span>,<span class="string">&#x27;abc&#x27;</span>,<span class="string">&#x27;abc&#x27;</span>,<span class="string">&#x27;abc&#x27;</span>,<span class="string">&#x27;abc&#x27;</span>);</span><br><span class="line"><span class="keyword">insert</span> <span class="keyword">into</span> tt(id,c1) <span class="keyword">values</span>(<span class="number">1</span>,<span class="string">&#x27;abc&#x27;</span>);</span><br><span class="line"><span class="keyword">insert</span> <span class="keyword">into</span> tt(id,c2) <span class="keyword">values</span>(<span class="number">2</span>,<span class="string">&#x27;abc&#x27;</span>);</span><br><span class="line"><span class="keyword">insert</span> <span class="keyword">into</span> tt(id,c3) <span class="keyword">values</span>(<span class="number">3</span>,<span class="string">&#x27;abc&#x27;</span>);</span><br><span class="line"><span class="keyword">insert</span> <span class="keyword">into</span> tt(id,c4) <span class="keyword">values</span>(<span class="number">4</span>,<span class="string">&#x27;abc&#x27;</span>);</span><br></pre></td></tr></table></figure>

<h3 id="观察日志："><a href="#观察日志：" class="headerlink" title="观察日志："></a>观察日志：</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">观察日志使用的命令就是 onlog -n xxx -l</span></span><br><span class="line">addr     len  type     xid      id link</span><br><span class="line">800bc    92   HINSERT  51       0  80084    90010c   101      27</span><br><span class="line">         5c000000 00002800 12410100 00000000 \.....(. .A......</span><br><span class="line">         00000000 00000000 33000000 84000800 ........ 3.......</span><br><span class="line">         37b9a400 0c019000 0c019000 01010000 7....... ........</span><br><span class="line">         1b000000 00000000 00000000 000000c2 ........ ........</span><br><span class="line">         00000000 61626361 62632020 20202020 ....abca bc</span><br><span class="line">         00036162 63000400 61626300          ..abc... abc.</span><br><span class="line"></span><br><span class="line">81050    88   HINSERT  51       0  81018    90010c   102      22</span><br><span class="line">         58000000 00002800 12010000 00000000 X.....(. ........</span><br><span class="line">         00000000 00000000 33000000 18100800 ........ 3.......</span><br><span class="line">         3bb9a400 0c019000 0c019000 02010000 ;....... ........</span><br><span class="line">         16000004 00000000 00000000 000000c2 ........ ........</span><br><span class="line">         00000001 61626300 20202020 20202020 ....abc.</span><br><span class="line">         00010000 01010000                   ........</span><br><span class="line"></span><br><span class="line">82050    88   HINSERT  51       0  82018    90010c   103      22</span><br><span class="line">         58000000 00002800 12010000 00000000 X.....(. ........</span><br><span class="line">         00000000 00000000 33000000 18200800 ........ 3.... ..</span><br><span class="line">         3fb9a400 0c019000 0c019000 03010000 ?....... ........</span><br><span class="line">         16000004 00000000 00000000 000000c2 ........ ........</span><br><span class="line">         00000002 00202061 62632020 20202020 .....  a bc</span><br><span class="line">         00010000 01019000                   ........</span><br><span class="line"></span><br><span class="line">83050    88   HINSERT  51       0  83018    90010c   104      24</span><br><span class="line">         58000000 00002800 12010000 00000000 X.....(. ........</span><br><span class="line">         00000000 00000000 33000000 18300800 ........ 3....0..</span><br><span class="line">         43b9a400 0c019000 0c019000 04010000 C....... ........</span><br><span class="line">         18000004 00000000 00000000 000000c2 ........ ........</span><br><span class="line">         00000003 00202000 20202020 20202020 .....  .</span><br><span class="line">         00036162 63000101                   ..abc...</span><br><span class="line"></span><br><span class="line">84050    92   HINSERT  51       0  84018    90010c   105      25</span><br><span class="line">         5c000000 00002800 12010000 00000000 \.....(. ........</span><br><span class="line">         00000000 00000000 33000000 18400800 ........ 3....@..</span><br><span class="line">         47b9a400 0c019000 0c019000 05010000 G....... ........</span><br><span class="line">         19000004 00000000 00000000 000000c2 ........ ........</span><br><span class="line">         00000004 00202000 20202020 20202020 .....  .</span><br><span class="line">         00010000 04006162 63000000          ......ab c...</span><br></pre></td></tr></table></figure>

<h3 id="观察小结："><a href="#观察小结：" class="headerlink" title="观察小结："></a>观察小结：</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">- 表的行最大长度row size = 29字节，其中表真实数据是24字节，varchar额外需要2字节，lvarchar额外需要3字节。</span><br><span class="line">- varchar额外的2个字节表示： 0001 即实际varchar存储了1个字节。 000100表示存储了1个字节，00表示varchar字段为空。</span><br><span class="line">- lvarchar额外的3个字节表示： 000400 即实际lvarchar存储了4-1个字节。 000101..表示存储了1-1个字节，后面紧跟的01表lvrchar字段为空。</span><br><span class="line">- insert 操作，逻辑日志会把所以字段都赋值，不管是不是在insert语句中指定的字段。</span><br><span class="line">- char 默认赋值为0x20 即“空格”</span><br><span class="line">- varchar 默认赋值为 0x000100 即空</span><br><span class="line">- lvarchar 默认赋值为0x000101 即空</span><br><span class="line">- 简言之，lvarchar长度后面的第一个字节00表示非空，01表示空。这个第一个字节位是比varchar多出的一个控制标识位。</span><br></pre></td></tr></table></figure>

<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">- varchar 的上限是：  32765</span><br><span class="line">- lvarchar 的上限是： 32739</span><br></pre></td></tr></table></figure>



<h2 id="update测试："><a href="#update测试：" class="headerlink" title="update测试："></a>update测试：</h2><h3 id="更新5条记录："><a href="#更新5条记录：" class="headerlink" title="更新5条记录："></a>更新5条记录：</h3><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">update</span> tt <span class="keyword">set</span> id <span class="operator">=</span> <span class="number">99</span> <span class="keyword">where</span> id <span class="operator">=</span> <span class="number">0</span>;</span><br><span class="line"><span class="keyword">update</span> tt <span class="keyword">set</span> c1 <span class="operator">=</span> <span class="string">&#x27;aaa&#x27;</span> <span class="keyword">where</span> id <span class="operator">=</span> <span class="number">1</span>;</span><br><span class="line"><span class="keyword">update</span> tt <span class="keyword">set</span> c2 <span class="operator">=</span> <span class="string">&#x27;bbb&#x27;</span> <span class="keyword">where</span> id <span class="operator">=</span> <span class="number">2</span>;</span><br><span class="line"><span class="keyword">update</span> tt <span class="keyword">set</span> c3 <span class="operator">=</span> <span class="string">&#x27;ccc&#x27;</span> <span class="keyword">where</span> id <span class="operator">=</span> <span class="number">3</span>;</span><br><span class="line"><span class="keyword">update</span> tt <span class="keyword">set</span> c4 <span class="operator">=</span> <span class="string">&#x27;ddd&#x27;</span> <span class="keyword">where</span> id <span class="operator">=</span> <span class="number">4</span>;</span><br></pre></td></tr></table></figure>

<h3 id="观察日志：-1"><a href="#观察日志：-1" class="headerlink" title="观察日志："></a>观察日志：</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br></pre></td><td class="code"><pre><span class="line">addr     len  type     xid      id link</span><br><span class="line">f5018    56   BEGIN    51       24 0        09/27/2023 00:08:42 43       gbasedbt</span><br><span class="line">         38000000 18000100 00000000 00000000 8....... ........</span><br><span class="line">         00000000 00000000 33000000 00000000 ........ 3.......</span><br><span class="line">         0bc1a400 00000000 caaa1365 00000000 ........ ...e....</span><br><span class="line">         ef030000 2b000000   </span><br><span class="line">f5050    92   HUPBEF   51       0  f5018    90010c   101      27</span><br><span class="line">         5c000000 00002a00 12012000 00000000 \.....*. .. .....</span><br><span class="line">         00000000 00000000 33000000 18500f00 ........ 3....P..</span><br><span class="line">         0bc1a400 0c019000 0c019000 01010000 ........ ........</span><br><span class="line">         1b000000 00000000 00000000 000000c6 ........ ........</span><br><span class="line">         00000000 61626361 62632020 20202020 ....abca bc</span><br><span class="line">         00036162 63000400 61626320          ..abc... abc</span><br><span class="line">f50ac    92   HUPAFT   51       0  f5050    90010c   101      27</span><br><span class="line">         5c000000 00002b00 12012000 00000000 \.....+. .. .....</span><br><span class="line">         00000000 00000000 33000000 50500f00 ........ 3...PP..</span><br><span class="line">         0bc1a400 0c019000 0c019000 01010000 ........ ........</span><br><span class="line">         1b000000 00000000 00000000 000000c6 ........ ........</span><br><span class="line">         00000063 61626361 62632020 20202020 ...cabca bc</span><br><span class="line">         00036162 63000400 61626320          ..abc... abc</span><br><span class="line">f5108    56   COMMIT   51       0  f50ac    09/27/2023 00:08:42</span><br><span class="line">         38000000 00000200 10000000 00000000 8....... ........</span><br><span class="line">         00000000 00000000 33000000 ac500f00 ........ 3....P..</span><br><span class="line">         0bc1a400 00000000 caaa1365 01010000 ........ ...e....</span><br><span class="line">         caaa1365 00000000                   ...e....</span><br><span class="line"></span><br><span class="line">addr     len  type     xid      id link</span><br><span class="line">f6018    56   BEGIN    51       24 0        09/27/2023 00:08:42 43       gbasedbt</span><br><span class="line">         38000000 18000100 00000000 00000000 8....... ........</span><br><span class="line">         00000000 00000000 33000000 00000000 ........ 3.......</span><br><span class="line">         0fc1a400 00000000 caaa1365 00000000 ........ ...e....</span><br><span class="line">         ef030000 2b000000                   ....+...</span><br><span class="line">f6050    88   HUPBEF   51       0  f6018    90010c   102      22</span><br><span class="line">         58000000 00002a00 12012000 00000000 X.....*. .. .....</span><br><span class="line">         00000000 00000000 33000000 18600f00 ........ 3....`..</span><br><span class="line">         0fc1a400 0c019000 0c019000 02010000 ........ ........</span><br><span class="line">         16000000 00000000 00000000 000000c6 ........ ........</span><br><span class="line">         00000001 61626300 20202020 20202020 ....abc.</span><br><span class="line">         00010000 01011000                   ........</span><br><span class="line">f60a8    88   HUPAFT   51       0  f6050    90010c   102      22</span><br><span class="line">         58000000 00002b00 12012000 00000000 X.....+. .. .....</span><br><span class="line">         00000000 00000000 33000000 50600f00 ........ 3...P`..</span><br><span class="line">         0fc1a400 0c019000 0c019000 02010000 ........ ........</span><br><span class="line">         16000000 00000000 00000000 000000c6 ........ ........</span><br><span class="line">         00000001 61616100 20202020 20202020 ....aaa.</span><br><span class="line">         00010000 01010000                   ........</span><br><span class="line">f6100    56   COMMIT   51       0  f60a8    09/27/2023 00:08:42</span><br><span class="line">         38000000 00000200 10000000 00000000 8....... ........</span><br><span class="line">         00000000 00000000 33000000 a8600f00 ........ 3....`..</span><br><span class="line">         0fc1a400 00000000 caaa1365 02010000 ........ ...e....</span><br><span class="line">         caaa1365 00000000                   ...e....</span><br><span class="line"></span><br><span class="line">addr     len  type     xid      id link</span><br><span class="line">f7018    56   BEGIN    51       24 0        09/27/2023 00:08:42 43       gbasedbt</span><br><span class="line">         38000000 18000100 00000000 00000000 8....... ........</span><br><span class="line">         00000000 00000000 33000000 00000000 ........ 3.......</span><br><span class="line">         13c1a400 00000000 caaa1365 00000000 ........ ...e....</span><br><span class="line">         ef030000 2b000000                   ....+...</span><br><span class="line">f7050    88   HUPBEF   51       0  f7018    90010c   103      22</span><br><span class="line">         58000000 00002a00 12012000 00000000 X.....*. .. .....</span><br><span class="line">         00000000 00000000 33000000 18700f00 ........ 3....p..</span><br><span class="line">         13c1a400 0c019000 0c019000 03010000 ........ ........</span><br><span class="line">         16000000 00000000 00000000 000000c6 ........ ........</span><br><span class="line">         00000002 00202061 62632020 20202020 .....  a bc</span><br><span class="line">         00010000 01013207                   ......2.</span><br><span class="line">f70a8    88   HUPAFT   51       0  f7050    90010c   103      22</span><br><span class="line">         58000000 00002b00 12012000 00000000 X.....+. .. .....</span><br><span class="line">         00000000 00000000 33000000 50700f00 ........ 3...Pp..</span><br><span class="line">         13c1a400 0c019000 0c019000 03010000 ........ ........</span><br><span class="line">         16000000 00000000 00000000 000000c6 ........ ........</span><br><span class="line">         00000002 00202062 62622020 20202020 .....  b bb</span><br><span class="line">         00010000 01010000                   ........</span><br><span class="line">f7100    56   COMMIT   51       0  f70a8    09/27/2023 00:08:42</span><br><span class="line">         38000000 00000200 10000000 00000000 8....... ........</span><br><span class="line">         00000000 00000000 33000000 a8700f00 ........ 3....p..</span><br><span class="line">         13c1a400 00000000 caaa1365 03010000 ........ ...e....</span><br><span class="line">         caaa1365 00000000                   ...e....</span><br><span class="line"></span><br><span class="line">addr     len  type     xid      id link</span><br><span class="line">f8018    56   BEGIN    51       24 0        09/27/2023 00:08:42 43       gbasedbt</span><br><span class="line">         38000000 18000100 00000000 00000000 8....... ........</span><br><span class="line">         00000000 00000000 33000000 00000000 ........ 3.......</span><br><span class="line">         17c1a400 00000000 caaa1365 00000000 ........ ...e....</span><br><span class="line">         ef030000 2b000000                   ....+...</span><br><span class="line">f8050    88   HUPBEF   51       0  f8018    90010c   104      24</span><br><span class="line">         58000000 00002a00 12012000 00000000 X.....*. .. .....</span><br><span class="line">         00000000 00000000 33000000 18800f00 ........ 3.......</span><br><span class="line">         17c1a400 0c019000 0c019000 04010000 ........ ........</span><br><span class="line">         18000000 00000000 00000000 000000c6 ........ ........</span><br><span class="line">         00000003 00202000 20202020 20202020 .....  .</span><br><span class="line">         00036162 63000101                   ..abc...</span><br><span class="line">f80a8    88   HUPAFT   51       0  f8050    90010c   104      24</span><br><span class="line">         58000000 00002b00 12012000 00000000 X.....+. .. .....</span><br><span class="line">         00000000 00000000 33000000 50800f00 ........ 3...P...</span><br><span class="line">         17c1a400 0c019000 0c019000 04010000 ........ ........</span><br><span class="line">         18000000 00000000 00000000 000000c6 ........ ........</span><br><span class="line">         00000003 00202000 20202020 20202020 .....  .</span><br><span class="line">         00036363 63000101                   ..ccc...</span><br><span class="line">f8100    56   COMMIT   51       0  f80a8    09/27/2023 00:08:42</span><br><span class="line">         38000000 00000200 10000000 00000000 8....... ........</span><br><span class="line">         00000000 00000000 33000000 a8800f00 ........ 3.......</span><br><span class="line">         17c1a400 00000000 caaa1365 04010000 ........ ...e....</span><br><span class="line">         caaa1365 00000000                   ...e....</span><br><span class="line"></span><br><span class="line">addr     len  type     xid      id link</span><br><span class="line">f9018    56   BEGIN    51       24 0        09/27/2023 00:08:43 43       gbasedbt</span><br><span class="line">         38000000 18000100 00000000 00000000 8....... ........</span><br><span class="line">         00000000 00000000 33000000 00000000 ........ 3.......</span><br><span class="line">         1bc1a400 00000000 cbaa1365 00000000 ........ ...e....</span><br><span class="line">         ef030000 2b000000                   ....+...</span><br><span class="line">f9050    92   HUPBEF   51       0  f9018    90010c   105      25</span><br><span class="line">         5c000000 00002a00 12012000 00000000 \.....*. .. .....</span><br><span class="line">         00000000 00000000 33000000 18900f00 ........ 3.......</span><br><span class="line">         1bc1a400 0c019000 0c019000 05010000 ........ ........</span><br><span class="line">         19000000 00000000 00000000 000000c6 ........ ........</span><br><span class="line">         00000004 00202000 20202020 20202020 .....  .</span><br><span class="line">         00010000 04006162 63000000          ......ab c...</span><br><span class="line">f90ac    92   HUPAFT   51       0  f9050    90010c   105      25</span><br><span class="line">         5c000000 00002b00 12012000 00000000 \.....+. .. .....</span><br><span class="line">         00000000 00000000 33000000 50900f00 ........ 3...P...</span><br><span class="line">         1bc1a400 0c019000 0c019000 05010000 ........ ........</span><br><span class="line">         19000000 00000000 00000000 000000c6 ........ ........</span><br><span class="line">         00000004 00202000 20202020 20202020 .....  .</span><br><span class="line">         00010000 04006464 64000200          ......dd d...</span><br><span class="line">f9108    56   COMMIT   51       0  f90ac    09/27/2023 00:08:43</span><br><span class="line">         38000000 00000200 10000000 00000000 8....... ........</span><br><span class="line">         00000000 00000000 33000000 ac900f00 ........ 3.......</span><br><span class="line">         1bc1a400 00000000 cbaa1365 05010000 ........ ...e....</span><br><span class="line">         cbaa1365 00000000                   ...e....</span><br><span class="line">[gbasedbt@wei07 ~]$</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h3 id="观察小结：-1"><a href="#观察小结：-1" class="headerlink" title="观察小结："></a>观察小结：</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">- 如果表里面不存在可变长字段，那么update是不会存储，变动前后行数据的。而只存储变动前后对应字节的的内容。</span><br><span class="line">- int类型占用4个字节，99对应0x63，这是数字对应。</span><br><span class="line">- char/varchar/lvarchar，是编码对应。包括数字字符。</span><br><span class="line">- 可以很简单的从前后镜像观察得到表的DML操作内容。</span><br></pre></td></tr></table></figure>



<p>延展：如果表里面不包含varchar字段，那么update日志不会包含前后镜像</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">可以发现表里面不包含varchar字段时update日志只有：BEGIN + HUPDAT + COMMIT ；并没有前镜像页，和后镜像页.</span> </span><br><span class="line">addr     len  type     xid      id link</span><br><span class="line">19018    56   BEGIN    51       24 0        09/26/2023 22:36:29 4        gbasedbt</span><br><span class="line">         38000000 18000100 00000000 00000000 8....... ........</span><br><span class="line">         00000000 00000000 33000000 00000000 ........ 3.......</span><br><span class="line">         23b2a400 00000000 2d951365 00000000 #....... -..e....</span><br><span class="line">         ef030000 04000000                   ........</span><br><span class="line">19050    80   HUPDAT   51       0  19018    90010c   103      0        16  16  1</span><br><span class="line">         50000000 00004900 12002000 00000000 P.....I. .. .....</span><br><span class="line">         00000000 00000000 33000000 18900100 ........ 3.......</span><br><span class="line">         23b2a400 0c019000 0c019000 03010000 #....... ........</span><br><span class="line">         00000000 10001000 01000000 00000000 ........ ........</span><br><span class="line">         7075626c 00070004 61626320 64656620 publ.... abc def</span><br><span class="line">190a0    56   COMMIT   51       0  19050    09/26/2023 22:36:29</span><br><span class="line">         38000000 00000200 10000000 00000000 8....... ........</span><br><span class="line">         00000000 00000000 33000000 50900100 ........ 3...P...</span><br><span class="line">         23b2a400 00000000 2d951365 03010000 #....... -..e....</span><br><span class="line">         2d951365 00000000                   -..e....</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>注明： 对于不包含varchar字段的表的逻辑日志解读，此处不先做展开。</p>
<hr>
<p>​		下文打算先写一下从逻辑日志里面反向推导出DML语句的工具，当然我们先不做太复杂的工具，例如我们先不考虑事务，多条语句，多行数据，特殊字段类型，等情况，我们先做一下最简单的单行变动的DML语句回推。</p>
<h2 id="打捞条件准备"><a href="#打捞条件准备" class="headerlink" title="打捞条件准备"></a>打捞条件准备</h2><h5 id="4个文件"><a href="#4个文件" class="headerlink" title="4个文件"></a>4个文件</h5><p>打捞前请先准备好这4个文件： 逻辑日备份文件，insert语句执行的位置文件，update语句执行的位置文件，表的字段信息文件。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">char *f_llog=&quot;/home/gbasedbt/wangwei/gbase8sTabDML/wei07_108_Log0000000024&quot;;</span><br><span class="line">char *f_insert=&quot;/home/gbasedbt/wangwei/gbase8sTabDML/insert.llog&quot;;</span><br><span class="line">char *f_update=&quot;/home/gbasedbt/wangwei/gbase8sTabDML/update.llog&quot;;</span><br><span class="line">char *f_column=&quot;/home/gbasedbt/wangwei/gbase8sTabDML/column.llog&quot;;</span><br></pre></td></tr></table></figure>



<ul>
<li>表结构</li>
</ul>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">create</span> <span class="keyword">table</span> tt (id <span class="type">int</span>, c1 <span class="type">char</span>(<span class="number">3</span>),c2 <span class="type">char</span>(<span class="number">9</span>),c3 <span class="type">varchar</span>(<span class="number">4</span>), c4 lvarchar(<span class="number">4</span>));</span><br></pre></td></tr></table></figure>

<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">[root@wei07 wei06-tab-dml-demo]# cat /home/gbasedbt/wangwei/gbase8sTabDML/column.llog</span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">name  <span class="built_in">type</span>  size</span></span><br><span class="line">id int 4</span><br><span class="line">c1 char 3</span><br><span class="line">c2 char 9</span><br><span class="line">c3 varchar 4</span><br><span class="line">c4 lvarchar 4</span><br><span class="line">  </span><br></pre></td></tr></table></figure>

<ul>
<li>逻辑日志备份</li>
</ul>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">/home/gbasedbt/wangwei/gbase8sTabDML/wei07_108_Log0000000024</span><br></pre></td></tr></table></figure>

<ul>
<li><p>逻辑日志insert开始位置及长度</p>
<p>cat &gt; &#x2F;home&#x2F;gbasedbt&#x2F;wangwei&#x2F;gbase8sTabDML&#x2F;insert.llog</p>
</li>
</ul>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">begin   len  <span class="built_in">type</span></span> </span><br><span class="line">800bc 92 HINSERT</span><br><span class="line">81050 88 HINSERT</span><br><span class="line">82050 88 HINSERT</span><br><span class="line">83050 88 HINSERT</span><br><span class="line">84050 92 HINSERT</span><br></pre></td></tr></table></figure>

<ul>
<li>逻辑日志updateBEF和updateAFT开始位置及长度</li>
</ul>
<p>cat &gt; &#x2F;home&#x2F;gbasedbt&#x2F;wangwei&#x2F;gbase8sTabDML&#x2F;update.llog</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">begin   len  BEF_type    begin   len  AFT_type</span> </span><br><span class="line">f5050 92 HUPBEF f50ac 92 HUPAFT</span><br><span class="line">f6050 88 HUPBEF f60a8 88 HUPAFT</span><br><span class="line">f7050 88 HUPBEF f70a8 88 HUPAFT</span><br><span class="line">f8050 88 HUPBEF f80a8 88 HUPAFT</span><br><span class="line">f9050 92 HUPBEF f90ac 92 HUPAFT</span><br></pre></td></tr></table></figure>

<h2 id="从insert逻辑日志中捞出insert语句"><a href="#从insert逻辑日志中捞出insert语句" class="headerlink" title="从insert逻辑日志中捞出insert语句"></a>从insert逻辑日志中捞出insert语句</h2><h5 id="从逻辑日志中捞取insertSQL语句的c程序代码"><a href="#从逻辑日志中捞取insertSQL语句的c程序代码" class="headerlink" title="从逻辑日志中捞取insertSQL语句的c程序代码"></a>从逻辑日志中捞取insertSQL语句的c程序代码</h5><figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br><span class="line">201</span><br><span class="line">202</span><br><span class="line">203</span><br><span class="line">204</span><br><span class="line">205</span><br><span class="line">206</span><br><span class="line">207</span><br><span class="line">208</span><br><span class="line">209</span><br><span class="line">210</span><br><span class="line">211</span><br><span class="line">212</span><br><span class="line">213</span><br><span class="line">214</span><br><span class="line">215</span><br><span class="line">216</span><br><span class="line">217</span><br><span class="line">218</span><br><span class="line">219</span><br><span class="line">220</span><br><span class="line">221</span><br><span class="line">222</span><br><span class="line">223</span><br><span class="line">224</span><br><span class="line">225</span><br><span class="line">226</span><br><span class="line">227</span><br><span class="line">228</span><br><span class="line">229</span><br><span class="line">230</span><br><span class="line">231</span><br><span class="line">232</span><br><span class="line">233</span><br><span class="line">234</span><br><span class="line">235</span><br><span class="line">236</span><br><span class="line">237</span><br><span class="line">238</span><br><span class="line">239</span><br><span class="line">240</span><br><span class="line">241</span><br><span class="line">242</span><br><span class="line">243</span><br><span class="line">244</span><br><span class="line">245</span><br><span class="line">246</span><br><span class="line">247</span><br><span class="line">248</span><br><span class="line">249</span><br><span class="line">250</span><br><span class="line">251</span><br><span class="line">252</span><br><span class="line">253</span><br><span class="line">254</span><br><span class="line">255</span><br><span class="line">256</span><br><span class="line">257</span><br><span class="line">258</span><br><span class="line">259</span><br><span class="line">260</span><br><span class="line">261</span><br><span class="line">262</span><br><span class="line">263</span><br><span class="line">264</span><br><span class="line">265</span><br><span class="line">266</span><br><span class="line">267</span><br><span class="line">268</span><br><span class="line">269</span><br><span class="line">270</span><br><span class="line">271</span><br><span class="line">272</span><br><span class="line">273</span><br><span class="line">274</span><br><span class="line">275</span><br><span class="line">276</span><br><span class="line">277</span><br><span class="line">278</span><br><span class="line">279</span><br><span class="line">280</span><br><span class="line">281</span><br><span class="line">282</span><br><span class="line">283</span><br><span class="line">284</span><br><span class="line">285</span><br><span class="line">286</span><br><span class="line">287</span><br><span class="line">288</span><br><span class="line">289</span><br><span class="line">290</span><br><span class="line">291</span><br><span class="line">292</span><br><span class="line">293</span><br><span class="line">294</span><br><span class="line">295</span><br><span class="line">296</span><br><span class="line">297</span><br><span class="line">298</span><br><span class="line">299</span><br><span class="line">300</span><br><span class="line">301</span><br><span class="line">302</span><br><span class="line">303</span><br><span class="line">304</span><br><span class="line">305</span><br><span class="line">306</span><br><span class="line">307</span><br><span class="line">308</span><br><span class="line">309</span><br><span class="line">310</span><br><span class="line">311</span><br><span class="line">312</span><br><span class="line">313</span><br><span class="line">314</span><br><span class="line">315</span><br><span class="line">316</span><br><span class="line">317</span><br><span class="line">318</span><br><span class="line">319</span><br><span class="line">320</span><br><span class="line">321</span><br><span class="line">322</span><br><span class="line">323</span><br><span class="line">324</span><br><span class="line">325</span><br><span class="line">326</span><br><span class="line">327</span><br><span class="line">328</span><br><span class="line">329</span><br><span class="line">330</span><br><span class="line">331</span><br><span class="line">332</span><br><span class="line">333</span><br><span class="line">334</span><br><span class="line">335</span><br><span class="line">336</span><br><span class="line">337</span><br><span class="line">338</span><br><span class="line">339</span><br><span class="line">340</span><br><span class="line">341</span><br><span class="line">342</span><br><span class="line">343</span><br><span class="line">344</span><br><span class="line">345</span><br><span class="line">346</span><br><span class="line">347</span><br><span class="line">348</span><br><span class="line">349</span><br><span class="line">350</span><br><span class="line">351</span><br><span class="line">352</span><br><span class="line">353</span><br><span class="line">354</span><br><span class="line">355</span><br><span class="line">356</span><br><span class="line">357</span><br><span class="line">358</span><br><span class="line">359</span><br><span class="line">360</span><br><span class="line">361</span><br><span class="line">362</span><br><span class="line">363</span><br><span class="line">364</span><br><span class="line">365</span><br><span class="line">366</span><br><span class="line">367</span><br><span class="line">368</span><br><span class="line">369</span><br><span class="line">370</span><br><span class="line">371</span><br><span class="line">372</span><br><span class="line">373</span><br><span class="line">374</span><br><span class="line">375</span><br><span class="line">376</span><br><span class="line">377</span><br><span class="line">378</span><br><span class="line">379</span><br><span class="line">380</span><br><span class="line">381</span><br><span class="line">382</span><br><span class="line">383</span><br><span class="line">384</span><br><span class="line">385</span><br><span class="line">386</span><br><span class="line">387</span><br><span class="line">388</span><br><span class="line">389</span><br><span class="line">390</span><br><span class="line">391</span><br><span class="line">392</span><br><span class="line">393</span><br><span class="line">394</span><br><span class="line">395</span><br><span class="line">396</span><br><span class="line">397</span><br><span class="line">398</span><br><span class="line">399</span><br><span class="line">400</span><br><span class="line">401</span><br><span class="line">402</span><br><span class="line">403</span><br><span class="line">404</span><br><span class="line">405</span><br><span class="line">406</span><br><span class="line">407</span><br><span class="line">408</span><br><span class="line">409</span><br><span class="line">410</span><br><span class="line">411</span><br><span class="line">412</span><br><span class="line">413</span><br><span class="line">414</span><br><span class="line">415</span><br><span class="line">416</span><br><span class="line">417</span><br><span class="line">418</span><br><span class="line">419</span><br><span class="line">420</span><br><span class="line">421</span><br><span class="line">422</span><br><span class="line">423</span><br><span class="line">424</span><br><span class="line">425</span><br><span class="line">426</span><br><span class="line">427</span><br><span class="line">428</span><br><span class="line">429</span><br><span class="line">430</span><br><span class="line">431</span><br><span class="line">432</span><br><span class="line">433</span><br><span class="line">434</span><br><span class="line">435</span><br><span class="line">436</span><br><span class="line">437</span><br><span class="line">438</span><br><span class="line">439</span><br><span class="line">440</span><br><span class="line">441</span><br><span class="line">442</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;stdio.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;stdlib.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;string.h&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="comment">/*</span></span><br><span class="line"><span class="comment"> *语句：</span></span><br><span class="line"><span class="comment"> * drop table if exists tt;</span></span><br><span class="line"><span class="comment"> * create table tt (id int, c1 char(3),c2 char(9),c3 varchar(4), c4 lvarchar(4));</span></span><br><span class="line"><span class="comment"> * </span></span><br><span class="line"><span class="comment"> * insert into tt values(0,&#x27;abc&#x27;,&#x27;abc&#x27;,&#x27;abc&#x27;,&#x27;abc&#x27;);</span></span><br><span class="line"><span class="comment"> * insert into tt(id,c1) values(1,&#x27;abc&#x27;);</span></span><br><span class="line"><span class="comment"> * insert into tt(id,c2) values(2,&#x27;abc&#x27;);</span></span><br><span class="line"><span class="comment"> * insert into tt(id,c3) values(3,&#x27;abc&#x27;);</span></span><br><span class="line"><span class="comment"> * insert into tt(id,c4) values(4,&#x27;abc&#x27;);</span></span><br><span class="line"><span class="comment"> * </span></span><br><span class="line"><span class="comment"> * update tt set id = 99 where id = 0;</span></span><br><span class="line"><span class="comment"> * update tt set c1 = &#x27;aaa&#x27; where id = 1;</span></span><br><span class="line"><span class="comment"> * update tt set c2 = &#x27;bbb&#x27; where id = 2;</span></span><br><span class="line"><span class="comment"> * update tt set c3 = &#x27;ccc&#x27; where id = 3;</span></span><br><span class="line"><span class="comment"> * update tt set c4 = &#x27;ddd&#x27; where id = 4;</span></span><br><span class="line"><span class="comment"> * </span></span><br><span class="line"><span class="comment"> *insert语句日志： /home/gbasedbt/wangwei/gbase8sTabDML/insert.llog</span></span><br><span class="line"><span class="comment"> * #begin   len  type </span></span><br><span class="line"><span class="comment"> * 800bc 92 HINSERT</span></span><br><span class="line"><span class="comment"> * 81050 88 HINSERT</span></span><br><span class="line"><span class="comment"> * 82050 88 HINSERT</span></span><br><span class="line"><span class="comment"> * 83050 88 HINSERT</span></span><br><span class="line"><span class="comment"> * 84050 92 HINSERT</span></span><br><span class="line"><span class="comment"> * </span></span><br><span class="line"><span class="comment"> *update语句日志： /home/gbasedbt/wangwei/gbase8sTabDML/update.llog</span></span><br><span class="line"><span class="comment"> * #begin   len  BEF_type    begin   len  AFT_type </span></span><br><span class="line"><span class="comment"> * f5050 92 HUPBEF f50ac 92 HUPAFT</span></span><br><span class="line"><span class="comment"> * f6050 88 HUPBEF f60a8 88 HUPAFT</span></span><br><span class="line"><span class="comment"> * f7050 88 HUPBEF f70a8 88 HUPAFT</span></span><br><span class="line"><span class="comment"> * f8050 88 HUPBEF f80a8 88 HUPAFT</span></span><br><span class="line"><span class="comment"> * f9050 92 HUPBEF f90ac 92 HUPAFT</span></span><br><span class="line"><span class="comment"> * </span></span><br><span class="line"><span class="comment"> *字段长度： /home/gbasedbt/wangwei/gbase8sTabDML/column.llog</span></span><br><span class="line"><span class="comment"> * #name  type  size</span></span><br><span class="line"><span class="comment"> * id int 4</span></span><br><span class="line"><span class="comment"> * c1 char 3</span></span><br><span class="line"><span class="comment"> * c2 char 9</span></span><br><span class="line"><span class="comment"> * c3 varchar 4</span></span><br><span class="line"><span class="comment"> * c4 lvarchar 4</span></span><br><span class="line"><span class="comment">*/</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">extern</span> <span class="type">void</span> <span class="title function_">deleteSpace</span><span class="params">(<span class="type">char</span> *str)</span>;</span><br><span class="line"><span class="keyword">extern</span> <span class="type">char</span> *<span class="title function_">utf8decode</span><span class="params">(<span class="type">char</span> *src)</span>;</span><br><span class="line"></span><br><span class="line"><span class="type">int</span> insert_row=<span class="number">5</span>;</span><br><span class="line"><span class="type">int</span> update_row=<span class="number">5</span>;</span><br><span class="line"></span><br><span class="line"><span class="type">char</span> *f_llog=<span class="string">&quot;/home/gbasedbt/wangwei/gbase8sTabDML/wei07_108_Log0000000024&quot;</span>;</span><br><span class="line"><span class="type">char</span> *f_insert=<span class="string">&quot;/home/gbasedbt/wangwei/gbase8sTabDML/insert.llog&quot;</span>;</span><br><span class="line"><span class="type">char</span> *f_update=<span class="string">&quot;/home/gbasedbt/wangwei/gbase8sTabDML/update.llog&quot;</span>;</span><br><span class="line"><span class="type">char</span> *f_column=<span class="string">&quot;/home/gbasedbt/wangwei/gbase8sTabDML/column.llog&quot;</span>;</span><br><span class="line"></span><br><span class="line"><span class="comment">// typedef struct TT</span></span><br><span class="line"><span class="comment">// &#123;</span></span><br><span class="line"><span class="comment">//    int id;</span></span><br><span class="line"><span class="comment">//    char c1[3];</span></span><br><span class="line"><span class="comment">//    char c2[9];</span></span><br><span class="line"><span class="comment">//    char c3[4];</span></span><br><span class="line"><span class="comment">//    char c4[4];</span></span><br><span class="line"><span class="comment">// &#125; tt_t;</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">typedef</span> <span class="class"><span class="keyword">struct</span> <span class="title">Column</span></span></span><br><span class="line"><span class="class">&#123;</span></span><br><span class="line">    <span class="type">char</span> c_name[<span class="number">30</span>];</span><br><span class="line">    <span class="type">char</span> c_type[<span class="number">30</span>];</span><br><span class="line">    <span class="type">int</span> c_def_len;</span><br><span class="line">    <span class="type">int</span> c_use_len;</span><br><span class="line">&#125; <span class="type">colunm_t</span>;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="keyword">typedef</span> <span class="class"><span class="keyword">struct</span> <span class="title">Insert</span></span></span><br><span class="line"><span class="class">&#123;</span></span><br><span class="line">    <span class="type">long</span> <span class="type">int</span> begin;</span><br><span class="line">    <span class="type">long</span> <span class="type">int</span> len;</span><br><span class="line">&#125; <span class="type">insert_begin_t</span>;</span><br><span class="line"></span><br><span class="line"><span class="keyword">typedef</span> <span class="class"><span class="keyword">struct</span> <span class="title">Update</span></span></span><br><span class="line"><span class="class">&#123;</span></span><br><span class="line">    <span class="type">long</span> <span class="type">int</span> bef_begin;</span><br><span class="line">    <span class="type">long</span> <span class="type">int</span> bef_len;</span><br><span class="line">    <span class="type">long</span> <span class="type">int</span> aft_begin;</span><br><span class="line">    <span class="type">long</span> <span class="type">int</span> aft_len;</span><br><span class="line">&#125; <span class="type">update_begin_t</span>;</span><br><span class="line"></span><br><span class="line"><span class="comment">// 临时存放字段值</span></span><br><span class="line"><span class="type">char</span> dst[<span class="number">32767</span>] = &#123;<span class="string">&#x27;\0&#x27;</span>&#125;;</span><br><span class="line"></span><br><span class="line"><span class="type">int</span> <span class="title function_">main</span><span class="params">(<span class="type">int</span> argc, <span class="type">char</span> <span class="type">const</span> *argv[])</span></span><br><span class="line">&#123;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">    <span class="comment">// 存放日志解析结果</span></span><br><span class="line">    <span class="comment">// tt_t inset[insert_row];</span></span><br><span class="line">    <span class="comment">// tt_t update_bef[update_row];</span></span><br><span class="line">    <span class="comment">// tt_t update_aft[update_row];</span></span><br><span class="line"></span><br><span class="line">    <span class="comment">// 存放insert begin len</span></span><br><span class="line">    <span class="type">insert_begin_t</span> i_b[insert_row];</span><br><span class="line">    <span class="type">update_begin_t</span> u_b[update_row];</span><br><span class="line">    </span><br><span class="line">    <span class="comment">// 打开输入文件</span></span><br><span class="line">    <span class="comment">// FILE *fp_llog=fopen(f_llog,&quot;rb&quot;);  //由于备份后的逻辑日志有包装，放弃直接读备份文件，改由读取备份文件onlog后的文件</span></span><br><span class="line">    FILE *fp_insert=fopen(f_insert,<span class="string">&quot;r&quot;</span>);</span><br><span class="line">    FILE *fp_update=fopen(f_update,<span class="string">&quot;r&quot;</span>);</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 读取insert文件</span></span><br><span class="line">    <span class="type">int</span> i = <span class="number">0</span>; </span><br><span class="line">    <span class="type">char</span> line[<span class="number">200</span>];</span><br><span class="line">    <span class="keyword">while</span> (fgets(line,<span class="number">200</span>,fp_insert))&#123;</span><br><span class="line">        <span class="type">char</span> *str_tmp_line[<span class="number">3</span>];</span><br><span class="line">        <span class="type">char</span> *str_tmp;</span><br><span class="line">        <span class="type">int</span> col=<span class="number">0</span>;</span><br><span class="line">        str_tmp = strtok(line,<span class="string">&quot; &quot;</span>);</span><br><span class="line">        <span class="keyword">while</span> (str_tmp != <span class="literal">NULL</span>)</span><br><span class="line">        &#123;</span><br><span class="line">            str_tmp_line[col]=str_tmp;</span><br><span class="line">            col++;</span><br><span class="line">            str_tmp=strtok(<span class="literal">NULL</span>,<span class="string">&quot; &quot;</span>);</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">if</span>(!<span class="built_in">strncmp</span>(str_tmp_line[<span class="number">2</span>],<span class="string">&quot;HINSERT&quot;</span>,<span class="number">7</span>))&#123;</span><br><span class="line">            <span class="built_in">sscanf</span>(str_tmp_line[<span class="number">0</span>],<span class="string">&quot;%x&quot;</span>,&amp;(i_b[i].begin));</span><br><span class="line">            i_b[i].len=atoi(str_tmp_line[<span class="number">1</span>]);</span><br><span class="line">            i++;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    i=<span class="number">0</span>;</span><br><span class="line">    <span class="keyword">while</span> (i &lt; insert_row)&#123;</span><br><span class="line">        <span class="built_in">printf</span>(<span class="string">&quot;%d %d\n&quot;</span>,i_b[i].begin,i_b[i].len);</span><br><span class="line">        i++;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 读取update文件</span></span><br><span class="line">    i = <span class="number">0</span>; </span><br><span class="line">    <span class="keyword">while</span> (fgets(line,<span class="number">200</span>,fp_update))&#123;</span><br><span class="line">        <span class="type">char</span> *str_tmp_line[<span class="number">6</span>];</span><br><span class="line">        <span class="type">char</span> *str_tmp;</span><br><span class="line">        <span class="type">int</span> col=<span class="number">0</span>;</span><br><span class="line">        str_tmp = strtok(line,<span class="string">&quot; &quot;</span>);</span><br><span class="line">        <span class="keyword">while</span> (str_tmp != <span class="literal">NULL</span>)</span><br><span class="line">        &#123;</span><br><span class="line">            str_tmp_line[col]=str_tmp;</span><br><span class="line">            col++;</span><br><span class="line">            str_tmp=strtok(<span class="literal">NULL</span>,<span class="string">&quot; &quot;</span>);</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">if</span>(!<span class="built_in">strncmp</span>(str_tmp_line[<span class="number">2</span>],<span class="string">&quot;HUPBEF&quot;</span>,<span class="number">7</span>))&#123;</span><br><span class="line">            <span class="built_in">sscanf</span>(str_tmp_line[<span class="number">0</span>],<span class="string">&quot;%x&quot;</span>,&amp;(u_b[i].bef_begin));</span><br><span class="line">            u_b[i].bef_len=atoi(str_tmp_line[<span class="number">1</span>]);</span><br><span class="line">            <span class="built_in">sscanf</span>(str_tmp_line[<span class="number">3</span>],<span class="string">&quot;%x&quot;</span>,&amp;(u_b[i].aft_begin));</span><br><span class="line">            u_b[i].aft_len=atoi(str_tmp_line[<span class="number">4</span>]);</span><br><span class="line">            i++;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    i=<span class="number">0</span>;</span><br><span class="line">    <span class="keyword">while</span> (i &lt; update_row)&#123;</span><br><span class="line">        <span class="built_in">printf</span>(<span class="string">&quot;%d %d %d %d\n&quot;</span>,u_b[i].bef_begin,u_b[i].bef_len,u_b[i].aft_begin,u_b[i].aft_len);</span><br><span class="line">        i++;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 截取逻辑日志段</span></span><br><span class="line">    <span class="comment">// //由于备份后的逻辑日志有包装，放弃直接读备份文件，改由读取备份文件onlog后的文件</span></span><br><span class="line">    <span class="comment">// fseek(fp_llog,i_b[0].begin+64+24576,SEEK_SET);</span></span><br><span class="line">    <span class="comment">// i=64;</span></span><br><span class="line">    <span class="comment">// int c;</span></span><br><span class="line">    <span class="comment">// while (i&lt;i_b[0].len)&#123;</span></span><br><span class="line">    <span class="comment">//     c=getc(fp_llog);</span></span><br><span class="line">    <span class="comment">//     printf(&quot;%02x\n&quot;,c);</span></span><br><span class="line">    <span class="comment">//     i++;</span></span><br><span class="line">    <span class="comment">// &#125;</span></span><br><span class="line"></span><br><span class="line">    <span class="comment">// 截取逻辑日志段</span></span><br><span class="line">    <span class="type">char</span> cmd[<span class="number">200</span>] = <span class="string">&quot;echo &#x27;\n&#x27; |onlog -d &quot;</span>;</span><br><span class="line">    <span class="built_in">strcat</span>(cmd,f_llog);</span><br><span class="line">    <span class="built_in">strcat</span>(cmd,<span class="string">&quot; -l &gt; /tmp/onlog.log&quot;</span>);</span><br><span class="line">    system(cmd);</span><br><span class="line">    <span class="comment">/*</span></span><br><span class="line"><span class="comment">     * 行读取 起始地址匹配</span></span><br><span class="line"><span class="comment">     * 取len/16行，向上取整</span></span><br><span class="line"><span class="comment">     * 取这些行的[9-44]左闭右开字节</span></span><br><span class="line"><span class="comment">     * 字节合并成字节串</span></span><br><span class="line"><span class="comment">    */</span></span><br><span class="line">    i=<span class="number">0</span>;</span><br><span class="line">    <span class="type">int</span> j=<span class="number">0</span>;</span><br><span class="line">    <span class="type">int</span> line_i = <span class="number">0</span>;</span><br><span class="line">    <span class="type">int</span> line_count = <span class="number">0</span>;</span><br><span class="line">    <span class="type">char</span> begin_0x[<span class="number">8</span>];</span><br><span class="line">    <span class="type">char</span> *data[insert_row];</span><br><span class="line">    <span class="keyword">while</span> (j&lt;insert_row)&#123;</span><br><span class="line">        data[j]=<span class="built_in">malloc</span>(<span class="number">2048</span>);</span><br><span class="line">        <span class="type">char</span> temp[<span class="number">36</span>] = &#123;<span class="string">&#x27;\0&#x27;</span>&#125;;</span><br><span class="line">        i = <span class="number">0</span>; </span><br><span class="line">        line_i = <span class="number">0</span>;</span><br><span class="line">        line_count=(i_b[j].len+<span class="number">16</span><span class="number">-1</span>)/<span class="number">16</span>;</span><br><span class="line">        FILE *fp_llog=fopen(<span class="string">&quot;/tmp/onlog.log&quot;</span>,<span class="string">&quot;r&quot;</span>);</span><br><span class="line">        <span class="keyword">while</span> (fgets(line,<span class="number">200</span>,fp_llog))&#123;</span><br><span class="line">            <span class="built_in">sprintf</span>(begin_0x,<span class="string">&quot;%x&quot;</span>,i_b[j].begin);</span><br><span class="line">            <span class="keyword">if</span> (line_i!=<span class="number">0</span> &amp;&amp; i&gt;(line_i+<span class="number">4</span>))&#123;</span><br><span class="line">                <span class="comment">// printf(&quot;%s&quot;,line);</span></span><br><span class="line">                <span class="comment">// 数据段合并成字节串</span></span><br><span class="line">                <span class="built_in">strncpy</span>(temp,line+<span class="number">9</span>,<span class="number">44</span><span class="number">-9</span>);</span><br><span class="line">                <span class="comment">// printf(&quot;--%s--\n&quot;,temp);</span></span><br><span class="line">                <span class="built_in">strcat</span>(data[j],temp);</span><br><span class="line">                <span class="keyword">if</span> (i==(line_i+line_count))&#123;</span><br><span class="line">                    <span class="keyword">break</span>;</span><br><span class="line">                &#125;</span><br><span class="line">            &#125;</span><br><span class="line">            <span class="keyword">if</span> (!<span class="built_in">memcmp</span>(begin_0x, line,<span class="built_in">strlen</span>(begin_0x)))&#123;</span><br><span class="line">                line_i=i;</span><br><span class="line">            &#125;</span><br><span class="line">            i++;</span><br><span class="line">        &#125;</span><br><span class="line">        fclose(fp_llog);</span><br><span class="line">        <span class="comment">// 去掉合并后的空格</span></span><br><span class="line">        deleteSpace(data[j]);</span><br><span class="line">        <span class="comment">// printf(&quot;%s\n&quot;,data[j]);</span></span><br><span class="line">        <span class="comment">// printf(&quot;%d\n&quot;,strlen(data[j]));</span></span><br><span class="line">        j++;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 接受字段的列表</span></span><br><span class="line">    <span class="type">colunm_t</span> columns[<span class="number">100</span>];</span><br><span class="line">    <span class="type">short</span> <span class="type">int</span> colNumber;</span><br><span class="line">    <span class="comment">// 读取字段文件输入,逐一以取字段信息</span></span><br><span class="line">    FILE *fp_column = fopen(f_column,<span class="string">&quot;r&quot;</span>);</span><br><span class="line">    j=<span class="number">0</span>;</span><br><span class="line">    <span class="keyword">while</span> (fgets(line,<span class="number">200</span>,fp_column))&#123;</span><br><span class="line">        <span class="comment">//忽略#开头的行</span></span><br><span class="line">        <span class="keyword">if</span> (!<span class="built_in">strncmp</span>(line,<span class="string">&quot;#&quot;</span>,<span class="number">1</span>)) <span class="keyword">continue</span>;</span><br><span class="line">        <span class="comment">//提取文本中表的：字段名称，类型，长度</span></span><br><span class="line">        <span class="type">char</span> *str_tmp_line[<span class="number">3</span>];</span><br><span class="line">        <span class="type">char</span> *str_tmp;</span><br><span class="line">        <span class="type">int</span> col = <span class="number">0</span>;</span><br><span class="line">        str_tmp = strtok(line,<span class="string">&quot; &quot;</span>);</span><br><span class="line">        <span class="keyword">while</span> (str_tmp != <span class="literal">NULL</span>)</span><br><span class="line">        &#123;</span><br><span class="line">            str_tmp_line[col]=str_tmp;</span><br><span class="line">            col++;</span><br><span class="line">            str_tmp=strtok(<span class="literal">NULL</span>,<span class="string">&quot; &quot;</span>);</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="type">colunm_t</span> column ;</span><br><span class="line">        <span class="built_in">strcpy</span>(column.c_name,str_tmp_line[<span class="number">0</span>]);</span><br><span class="line">        <span class="built_in">strcpy</span>(column.c_type,str_tmp_line[<span class="number">1</span>]);</span><br><span class="line">        column.c_def_len=atoi(str_tmp_line[<span class="number">2</span>]);</span><br><span class="line">        columns[j]=column;</span><br><span class="line">        j++;</span><br><span class="line">    &#125;</span><br><span class="line">    colNumber=j;</span><br><span class="line">    <span class="keyword">for</span>(i=<span class="number">0</span>;i&lt;colNumber;i++)&#123;</span><br><span class="line">        <span class="built_in">printf</span>(<span class="string">&quot;%s %s %d %d\n&quot;</span>,columns[i].c_name,columns[i].c_type,columns[i].c_def_len,columns[i].c_use_len);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">    <span class="comment">// 对字节串按表字段拆分</span></span><br><span class="line">    <span class="type">int</span> row_n;</span><br><span class="line">    <span class="keyword">for</span>(row_n=<span class="number">0</span>;row_n&lt;insert_row;row_n++)&#123;</span><br><span class="line">        <span class="comment">// 接受insert的值</span></span><br><span class="line">        <span class="type">char</span> sql[<span class="number">500</span>] =&#123;<span class="string">&#x27;\0&#x27;</span>&#125;;</span><br><span class="line">        <span class="type">char</span> *insert_sql_beg = <span class="string">&quot;insert into tt values ( &quot;</span>;</span><br><span class="line">        <span class="type">char</span> *insert_sql_end = <span class="string">&quot; );&quot;</span>;</span><br><span class="line">        <span class="built_in">strcpy</span>(sql,insert_sql_beg);</span><br><span class="line">        <span class="comment">//日志里面的一条data</span></span><br><span class="line">        <span class="comment">// printf(&quot;%s %d\n&quot;,data[row_n],strlen(data[row_n]));</span></span><br><span class="line">        <span class="type">char</span> *p = data[row_n];</span><br><span class="line">        <span class="comment">//用字段取拆分日志</span></span><br><span class="line">        <span class="keyword">for</span>(i=<span class="number">0</span>;i&lt;colNumber;i++)&#123;</span><br><span class="line">            <span class="comment">// printf(&quot;%d\n&quot;,i);</span></span><br><span class="line">            <span class="type">colunm_t</span> column = columns[i];</span><br><span class="line"></span><br><span class="line">            <span class="comment">// 处理 int</span></span><br><span class="line">            <span class="keyword">if</span> (!<span class="built_in">strcmp</span>(column.c_type,<span class="string">&quot;int&quot;</span>))&#123;</span><br><span class="line">                column.c_use_len = column.c_def_len;</span><br><span class="line">                <span class="type">char</span> var_id[<span class="number">9</span>] = &#123;<span class="string">&#x27;\0&#x27;</span>&#125; ;</span><br><span class="line">                <span class="keyword">for</span>(j=<span class="number">0</span>;j&lt;<span class="number">8</span>;j++)&#123;</span><br><span class="line">                    var_id[j]=*p++;</span><br><span class="line">                &#125;</span><br><span class="line">                <span class="comment">// printf(&quot;%s\n&quot;,var_id);</span></span><br><span class="line">                <span class="comment">//返回一个10进制数字的字符串</span></span><br><span class="line">                <span class="type">char</span> result[<span class="number">11</span>];</span><br><span class="line">                <span class="comment">//16进制字符串转int</span></span><br><span class="line">                <span class="type">int</span> v_int;</span><br><span class="line">                <span class="built_in">sscanf</span>(var_id,<span class="string">&quot;%x&quot;</span>,&amp;v_int);</span><br><span class="line">                <span class="comment">//int转字符串</span></span><br><span class="line">                <span class="built_in">sprintf</span>(result, <span class="string">&quot;%d&quot;</span>, v_int);</span><br><span class="line">                <span class="comment">//insert语句值拼接</span></span><br><span class="line">                <span class="built_in">strcat</span>(sql,result);</span><br><span class="line">                <span class="built_in">strcat</span>(sql,<span class="string">&quot;,&quot;</span>);</span><br><span class="line">            &#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">            <span class="comment">// 处理 char</span></span><br><span class="line">            <span class="keyword">if</span> (!<span class="built_in">strcmp</span>(column.c_type,<span class="string">&quot;char&quot;</span>))&#123;</span><br><span class="line">                column.c_use_len = column.c_def_len;</span><br><span class="line">                <span class="type">char</span> var_c1[column.c_use_len*<span class="number">2</span>+<span class="number">1</span>];</span><br><span class="line">                var_c1[column.c_use_len*<span class="number">2</span>]=<span class="string">&#x27;\0&#x27;</span>;</span><br><span class="line">                <span class="keyword">for</span>(j=<span class="number">0</span>;j&lt;column.c_use_len*<span class="number">2</span>;j++)&#123;</span><br><span class="line">                    var_c1[j]=*p++;</span><br><span class="line">                &#125;</span><br><span class="line">                <span class="comment">// printf(&quot;%s\n&quot;,var_c1);</span></span><br><span class="line">                <span class="comment">//空值判断</span></span><br><span class="line">                <span class="keyword">if</span> (var_c1[<span class="number">0</span>]==<span class="string">&#x27;0&#x27;</span> &amp;&amp; var_c1[<span class="number">1</span>]==<span class="string">&#x27;0&#x27;</span>)&#123;</span><br><span class="line">                    <span class="built_in">strcat</span>(sql,<span class="string">&quot;&#x27;&quot;</span>);</span><br><span class="line">                    <span class="built_in">strcat</span>(sql,<span class="string">&quot;&#x27;,&quot;</span>);  </span><br><span class="line">                    <span class="keyword">continue</span>;                  </span><br><span class="line">                &#125;</span><br><span class="line">                <span class="comment">//返回一个字节串</span></span><br><span class="line">                <span class="comment">//utf8 解码decode</span></span><br><span class="line">                utf8decode(var_c1);</span><br><span class="line">                <span class="comment">//insert语句值拼接</span></span><br><span class="line">                <span class="built_in">strcat</span>(sql,<span class="string">&quot;&#x27;&quot;</span>);</span><br><span class="line">                <span class="built_in">strcat</span>(sql,dst);</span><br><span class="line">                <span class="built_in">strcat</span>(sql,<span class="string">&quot;&#x27;,&quot;</span>);</span><br><span class="line">            &#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">            <span class="comment">// 处理 varchar</span></span><br><span class="line">            <span class="keyword">if</span> (!<span class="built_in">strcmp</span>(column.c_type,<span class="string">&quot;varchar&quot;</span>))&#123;</span><br><span class="line">                <span class="comment">//先取前2个字节</span></span><br><span class="line">                <span class="type">char</span> nc[<span class="number">5</span>]=&#123;<span class="string">&#x27;\0&#x27;</span>&#125;;</span><br><span class="line">                <span class="keyword">for</span> (j=<span class="number">0</span>;j&lt;<span class="number">4</span>;j++)&#123;</span><br><span class="line">                    nc[j]=*p++;</span><br><span class="line">                &#125;</span><br><span class="line">                <span class="comment">//16进制字符串转int</span></span><br><span class="line">                <span class="type">int</span> nc_i;</span><br><span class="line">                <span class="built_in">sscanf</span>(nc,<span class="string">&quot;%x&quot;</span>,&amp;nc_i);</span><br><span class="line">                <span class="comment">//再指定长度</span></span><br><span class="line">                column.c_use_len = nc_i;</span><br><span class="line">                <span class="comment">//再取字字符串</span></span><br><span class="line">                <span class="type">char</span> var_c2[column.c_use_len*<span class="number">2</span>+<span class="number">1</span>];</span><br><span class="line">                var_c2[column.c_use_len*<span class="number">2</span>]=<span class="string">&#x27;\0&#x27;</span>;</span><br><span class="line">                <span class="keyword">for</span>(j=<span class="number">0</span>;j&lt;column.c_use_len*<span class="number">2</span>;j++)&#123;</span><br><span class="line">                    var_c2[j]=*p++;</span><br><span class="line">                &#125;</span><br><span class="line">                <span class="comment">// printf(&quot;%s\n&quot;,var_c2);</span></span><br><span class="line">                <span class="comment">//空值判断</span></span><br><span class="line">                <span class="keyword">if</span> (var_c2[<span class="number">0</span>]==<span class="string">&#x27;0&#x27;</span> &amp;&amp; var_c2[<span class="number">1</span>]==<span class="string">&#x27;0&#x27;</span>)&#123;</span><br><span class="line">                    <span class="built_in">strcat</span>(sql,<span class="string">&quot;&#x27;&quot;</span>);</span><br><span class="line">                    <span class="built_in">strcat</span>(sql,<span class="string">&quot;&#x27;,&quot;</span>);  </span><br><span class="line">                    <span class="keyword">continue</span>;                  </span><br><span class="line">                &#125;</span><br><span class="line">                <span class="comment">//返回一个字节串</span></span><br><span class="line">                utf8decode(var_c2);</span><br><span class="line">                <span class="comment">//insert语句值拼接</span></span><br><span class="line">                <span class="built_in">strcat</span>(sql,<span class="string">&quot;&#x27;&quot;</span>);</span><br><span class="line">                <span class="built_in">strcat</span>(sql,dst);</span><br><span class="line">                <span class="built_in">strcat</span>(sql,<span class="string">&quot;&#x27;,&quot;</span>);</span><br><span class="line">            &#125;    </span><br><span class="line"></span><br><span class="line"></span><br><span class="line">            <span class="comment">// 处理 lvarchar</span></span><br><span class="line">            <span class="keyword">if</span> (!<span class="built_in">strcmp</span>(column.c_type,<span class="string">&quot;lvarchar&quot;</span>))&#123;</span><br><span class="line">                <span class="comment">//先取前2个字节</span></span><br><span class="line">                <span class="type">char</span> nc[<span class="number">5</span>]=&#123;<span class="string">&#x27;\0&#x27;</span>&#125;;</span><br><span class="line">                <span class="keyword">for</span> (j=<span class="number">0</span>;j&lt;<span class="number">4</span>;j++)&#123;</span><br><span class="line">                    nc[j]=*p++;</span><br><span class="line">                &#125;</span><br><span class="line">                <span class="comment">//16进制字符串转int</span></span><br><span class="line">                <span class="type">int</span> nc_i;</span><br><span class="line">                <span class="built_in">sscanf</span>(nc,<span class="string">&quot;%x&quot;</span>,&amp;nc_i);</span><br><span class="line">                <span class="comment">//再指定长度</span></span><br><span class="line">                column.c_use_len = nc_i<span class="number">-1</span>;</span><br><span class="line">                <span class="comment">//取1字节的控制位</span></span><br><span class="line">                p++;</span><br><span class="line">                p++;</span><br><span class="line">                <span class="comment">//再取字字符串</span></span><br><span class="line">                <span class="type">char</span> var_c3[column.c_use_len*<span class="number">2</span>+<span class="number">1</span>];</span><br><span class="line">                var_c3[column.c_use_len*<span class="number">2</span>]=<span class="string">&#x27;\0&#x27;</span>;</span><br><span class="line">                <span class="keyword">for</span>(j=<span class="number">0</span>;j&lt;column.c_use_len*<span class="number">2</span>;j++)&#123;</span><br><span class="line">                    var_c3[j]=*p++;</span><br><span class="line">                &#125;</span><br><span class="line">                <span class="comment">// printf(&quot;%s\n&quot;,var_c3);</span></span><br><span class="line">                <span class="comment">//返回一个字节串</span></span><br><span class="line">                utf8decode(var_c3);</span><br><span class="line">                <span class="comment">//insert语句值拼接</span></span><br><span class="line">                <span class="built_in">strcat</span>(sql,<span class="string">&quot;&#x27;&quot;</span>);</span><br><span class="line">                <span class="built_in">strcat</span>(sql,dst);</span><br><span class="line">                <span class="built_in">strcat</span>(sql,<span class="string">&quot;&#x27;,&quot;</span>);</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="type">char</span> sql_end[<span class="number">1000</span>]=&#123;<span class="string">&#x27;\0&#x27;</span>&#125;;</span><br><span class="line">        <span class="built_in">strncpy</span>(sql_end,sql,<span class="built_in">strlen</span>(sql)<span class="number">-1</span>);</span><br><span class="line">        <span class="built_in">strcat</span>(sql_end,insert_sql_end);</span><br><span class="line">        <span class="built_in">printf</span>(<span class="string">&quot;%s\n&quot;</span>,sql_end);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">    <span class="comment">// 关闭文件</span></span><br><span class="line">    fclose(fp_insert);</span><br><span class="line">    fclose(fp_update);</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="type">void</span> <span class="title function_">deleteSpace</span><span class="params">(<span class="type">char</span> *str)</span>&#123;</span><br><span class="line">    <span class="type">char</span> *str_c=str;</span><br><span class="line">    <span class="type">int</span> i,j =<span class="number">0</span>;</span><br><span class="line">    <span class="keyword">for</span>(i=<span class="number">0</span>;str[i]!=<span class="string">&#x27;\0&#x27;</span>;i++)&#123;</span><br><span class="line">        <span class="keyword">if</span>(str[i]!=<span class="string">&#x27; &#x27;</span>)</span><br><span class="line">            str_c[j++]=str[i];</span><br><span class="line">    &#125;</span><br><span class="line">    str_c[j]=<span class="string">&#x27;\0&#x27;</span>;</span><br><span class="line">    str=str_c;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="type">char</span> *<span class="title function_">utf8decode</span><span class="params">(<span class="type">char</span> *src)</span>&#123;</span><br><span class="line">    <span class="type">int</span> n;</span><br><span class="line">    n=<span class="built_in">strlen</span>(src);</span><br><span class="line">    <span class="keyword">if</span> (n==<span class="number">0</span>) &#123;</span><br><span class="line">        dst[<span class="number">0</span>]=<span class="string">&#x27;\0&#x27;</span>;</span><br><span class="line">        <span class="keyword">return</span> dst;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="type">char</span> cmd[n+<span class="number">20</span>];</span><br><span class="line">    <span class="built_in">strcpy</span>(cmd,<span class="string">&quot;utf8decode -s &quot;</span>);</span><br><span class="line">    <span class="built_in">strcat</span>(cmd,src);</span><br><span class="line">    FILE *fp = <span class="literal">NULL</span>;</span><br><span class="line">    fp = popen(cmd,<span class="string">&quot;r&quot;</span>);</span><br><span class="line">    <span class="keyword">if</span>(fp==<span class="literal">NULL</span>)&#123;</span><br><span class="line">        <span class="built_in">printf</span>(<span class="string">&quot;POPEN ERROR!\n&quot;</span>);</span><br><span class="line">        <span class="keyword">return</span> <span class="string">&quot;errot&quot;</span>;</span><br><span class="line">    &#125;   </span><br><span class="line">    dst[<span class="number">0</span>]=<span class="string">&#x27;\0&#x27;</span>;</span><br><span class="line">    <span class="type">char</span> buffer = fgetc(fp);</span><br><span class="line">    dst[<span class="number">0</span>]=buffer;</span><br><span class="line">    <span class="type">int</span> cnt =<span class="number">0</span>;</span><br><span class="line">    <span class="keyword">while</span> (!feof(fp))</span><br><span class="line">    &#123;</span><br><span class="line">        cnt++;</span><br><span class="line">        buffer=fgetc(fp);</span><br><span class="line">        dst[cnt]=buffer;</span><br><span class="line">    &#125;</span><br><span class="line">    dst[--cnt]=<span class="string">&#x27;\0&#x27;</span>;</span><br><span class="line">    pclose(fp);</span><br><span class="line">    <span class="keyword">return</span> dst;</span><br><span class="line">&#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h5 id="utf8字节码解码："><a href="#utf8字节码解码：" class="headerlink" title="utf8字节码解码："></a>utf8字节码解码：</h5><figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> main</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> <span class="string">&quot;fmt&quot;</span></span><br><span class="line"><span class="keyword">import</span> <span class="string">&quot;encoding/hex&quot;</span></span><br><span class="line"><span class="keyword">import</span> <span class="string">&quot;log&quot;</span></span><br><span class="line"><span class="keyword">import</span> <span class="string">&quot;flag&quot;</span></span><br><span class="line"></span><br><span class="line"><span class="comment">// 注明：这个程序可以用c写，由于时间问题先外挂golang解决。</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">var</span> src = flag.String(<span class="string">&quot;s&quot;</span>,<span class="string">&quot;616263&quot;</span>,<span class="string">&quot;decode utf8 []byte&quot;</span>)</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">func</span> <span class="title">main</span><span class="params">()</span></span>&#123;</span><br><span class="line">        flag.Parse()</span><br><span class="line">        src2 := []<span class="type">byte</span>(*src)</span><br><span class="line">        dst := <span class="built_in">make</span>([]<span class="type">byte</span>,hex.DecodedLen(<span class="built_in">len</span>(src2)))</span><br><span class="line">        n,err := hex.Decode(dst,src2)</span><br><span class="line">        <span class="keyword">if</span> err != <span class="literal">nil</span> &#123;</span><br><span class="line">           log.Fatal(err)</span><br><span class="line">        &#125;</span><br><span class="line">        fmt.Printf(<span class="string">&quot;%s\n&quot;</span>,dst[:n])</span><br><span class="line">&#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure>



<h5 id="编译执行，从逻辑日志中捞取insertSQL语句："><a href="#编译执行，从逻辑日志中捞取insertSQL语句：" class="headerlink" title="编译执行，从逻辑日志中捞取insertSQL语句："></a>编译执行，从逻辑日志中捞取insertSQL语句：</h5><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line">[root@wei07 wei06-tab-dml-demo]# gcc main.c  &amp;&amp; ./a.out </span><br><span class="line">524476 92</span><br><span class="line">528464 88</span><br><span class="line">532560 88</span><br><span class="line">536656 88</span><br><span class="line">540752 92</span><br><span class="line">1003600 92 1003692 92</span><br><span class="line">1007696 88 1007784 88</span><br><span class="line">1011792 88 1011880 88</span><br><span class="line">1015888 88 1015976 88</span><br><span class="line">1019984 92 1020076 92</span><br><span class="line">id int 4 0</span><br><span class="line">c1 char 3 0</span><br><span class="line">c2 char 9 0</span><br><span class="line">c3 varchar 4 0</span><br><span class="line">c4 lvarchar 4 0</span><br><span class="line">insert into tt values ( 0,&#x27;abc&#x27;,&#x27;abc      &#x27;,&#x27;abc&#x27;,&#x27;abc&#x27; );</span><br><span class="line">insert into tt values ( 1,&#x27;abc&#x27;,&#x27;&#x27;,&#x27;&#x27;,&#x27;&#x27; );</span><br><span class="line">insert into tt values ( 2,&#x27;&#x27;,&#x27;abc      &#x27;,&#x27;&#x27;,&#x27;&#x27; );</span><br><span class="line">insert into tt values ( 3,&#x27;&#x27;,&#x27;&#x27;,&#x27;abc&#x27;,&#x27;&#x27; );</span><br><span class="line">insert into tt values ( 4,&#x27;&#x27;,&#x27;&#x27;,&#x27;&#x27;,&#x27;abc&#x27; );</span><br><span class="line">[root@wei07 wei06-tab-dml-demo]# </span><br></pre></td></tr></table></figure>





<h2 id="从update逻辑日志中捞出update语句"><a href="#从update逻辑日志中捞出update语句" class="headerlink" title="从update逻辑日志中捞出update语句"></a>从update逻辑日志中捞出update语句</h2><p>​		有空再完善。。</p>
 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/SQL%E8%AF%AD%E5%8F%A5%E6%8F%90%E5%8F%96/" rel="tag">SQL语句提取</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/level3/" rel="tag">level3</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E8%87%AA%E7%A0%94/" rel="tag">自研</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E9%80%BB%E8%BE%91%E6%97%A5%E5%BF%97%E8%A7%A3%E6%9E%90/" rel="tag">逻辑日志解析</a></li></ul>

    </footer>
  </div>

   
   
  
</article>

    
    <article
  id="post-Java线程同步-银行取号叫号业务场景-md"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2023/08/20/Java%E7%BA%BF%E7%A8%8B%E5%90%8C%E6%AD%A5-%E9%93%B6%E8%A1%8C%E5%8F%96%E5%8F%B7%E5%8F%AB%E5%8F%B7%E4%B8%9A%E5%8A%A1%E5%9C%BA%E6%99%AF-md/"
    >Java线程同步--银行取号叫号业务场景.md</a> 
</h2>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2023/08/20/Java%E7%BA%BF%E7%A8%8B%E5%90%8C%E6%AD%A5-%E9%93%B6%E8%A1%8C%E5%8F%96%E5%8F%B7%E5%8F%AB%E5%8F%B7%E4%B8%9A%E5%8A%A1%E5%9C%BA%E6%99%AF-md/" class="article-date">
  <time datetime="2023-08-20T01:28:39.000Z" itemprop="datePublished">2023-08-20</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/Java/">Java</a>
  </div>
   
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <h3 id="示例：线程，并发，同步，队列"><a href="#示例：线程，并发，同步，队列" class="headerlink" title="示例：线程，并发，同步，队列"></a>示例：线程，并发，同步，队列</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> weidb.students;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> java.util.concurrent.ArrayBlockingQueue;</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">Test01</span> &#123;</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> <span class="keyword">throws</span> Exception&#123;</span><br><span class="line">        <span class="comment">// TODO 最大接收几个用户排队</span></span><br><span class="line">        <span class="type">int</span> <span class="variable">numCount</span> <span class="operator">=</span> <span class="number">4</span>;</span><br><span class="line"></span><br><span class="line">        <span class="comment">// TODO 号码池缓存个数</span></span><br><span class="line">        <span class="type">int</span> <span class="variable">numCache</span> <span class="operator">=</span> <span class="number">3</span>;</span><br><span class="line"></span><br><span class="line">        <span class="comment">// TODO 起始号码</span></span><br><span class="line">        <span class="type">int</span> numStart= <span class="number">3600</span>;</span><br><span class="line"></span><br><span class="line">        <span class="comment">// TODO 实例化： 号码总数，号码池，叫号队列</span></span><br><span class="line">        <span class="type">NumAll</span> <span class="variable">numAll</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">NumAll</span>(numCount,numStart);</span><br><span class="line">        <span class="type">Num</span> <span class="variable">num</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">Num</span>(numCache);</span><br><span class="line">        <span class="type">CallNum</span> <span class="variable">callNum</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">CallNum</span>(numCount);</span><br><span class="line"></span><br><span class="line">        <span class="comment">// TODO 号码池缓存号码</span></span><br><span class="line">        <span class="keyword">for</span> (<span class="type">int</span> i=<span class="number">0</span>;i&lt;numCache;i++)&#123;</span><br><span class="line">            numStart+=<span class="number">1</span>;</span><br><span class="line">            num.queue.put(numStart);</span><br><span class="line">            numAll.c++;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        <span class="comment">// TODO 并发取号</span></span><br><span class="line">        <span class="type">User</span> <span class="variable">user</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">User</span>(<span class="number">1001</span>,<span class="string">&quot;user01&quot;</span>,numAll,num,callNum);</span><br><span class="line">        user.start();</span><br><span class="line">        <span class="type">User</span> <span class="variable">user2</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">User</span>(<span class="number">1002</span>,<span class="string">&quot;user02&quot;</span>,numAll,num,callNum);</span><br><span class="line">        user2.start();</span><br><span class="line">        <span class="type">User</span> <span class="variable">user3</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">User</span>(<span class="number">1003</span>,<span class="string">&quot;user03&quot;</span>,numAll,num,callNum);</span><br><span class="line">        user3.start();</span><br><span class="line">        <span class="type">User</span> <span class="variable">user4</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">User</span>(<span class="number">1004</span>,<span class="string">&quot;user04&quot;</span>,numAll,num,callNum);</span><br><span class="line">        user4.start();</span><br><span class="line">        <span class="type">User</span> <span class="variable">user5</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">User</span>(<span class="number">1005</span>,<span class="string">&quot;user05&quot;</span>,numAll,num,callNum);</span><br><span class="line">        user5.start();</span><br><span class="line">        <span class="type">User</span> <span class="variable">user6</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">User</span>(<span class="number">1006</span>,<span class="string">&quot;user06&quot;</span>,numAll,num,callNum);</span><br><span class="line">        user6.start();</span><br><span class="line"></span><br><span class="line">        <span class="comment">// TODO 唤醒叫号队列</span></span><br><span class="line">        Thread.sleep(<span class="number">2000</span>);</span><br><span class="line">        <span class="keyword">synchronized</span>(callNum) &#123;</span><br><span class="line">            callNum.notifyAll();</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        <span class="comment">// TODO 叫号</span></span><br><span class="line">        <span class="keyword">for</span> (User user1 : CallNum.queueUser)&#123;</span><br><span class="line">            user1.work();</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">class</span> <span class="title class_">NumAll</span> &#123;</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="type">int</span>[] all;</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="type">int</span> <span class="variable">c</span> <span class="operator">=</span> <span class="number">0</span>;</span><br><span class="line">    <span class="keyword">public</span> <span class="title function_">NumAll</span><span class="params">(<span class="type">int</span> numCount,<span class="type">int</span> numStart)</span> &#123;</span><br><span class="line">        all = <span class="keyword">new</span> <span class="title class_">int</span>[numCount];</span><br><span class="line">        c = numStart;</span><br><span class="line">        <span class="keyword">for</span> (<span class="type">int</span> i=<span class="number">0</span>;i&lt;numCount;i++)&#123;</span><br><span class="line">            numStart+=<span class="number">1</span>;</span><br><span class="line">            all[i]=numStart;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">class</span> <span class="title class_">Num</span> &#123;</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> ArrayBlockingQueue&lt;Integer&gt; queue;</span><br><span class="line">    <span class="keyword">public</span> <span class="title function_">Num</span><span class="params">(<span class="type">int</span> numCache)</span> &#123;</span><br><span class="line">        queue=<span class="keyword">new</span> <span class="title class_">ArrayBlockingQueue</span>(numCache);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">class</span> <span class="title class_">CallNum</span> &#123;</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> ArrayBlockingQueue&lt;User&gt; queueUser;</span><br><span class="line">    <span class="keyword">public</span> <span class="title function_">CallNum</span><span class="params">(<span class="type">int</span> numCount)</span>&#123;</span><br><span class="line">        queueUser = <span class="keyword">new</span> <span class="title class_">ArrayBlockingQueue</span>&lt;&gt;(numCount);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">class</span> <span class="title class_">User</span> <span class="keyword">extends</span> <span class="title class_">Thread</span>&#123;</span><br><span class="line">    <span class="type">int</span> id;</span><br><span class="line">    String name;</span><br><span class="line">    NumAll numAll;</span><br><span class="line">    Num num;</span><br><span class="line">    <span class="type">int</span> num_c;</span><br><span class="line">    CallNum callNum;</span><br><span class="line"></span><br><span class="line">    <span class="meta">@Override</span></span><br><span class="line">    <span class="keyword">public</span> String <span class="title function_">toString</span><span class="params">()</span> &#123;</span><br><span class="line">        <span class="keyword">return</span> <span class="string">&quot;User&#123;&quot;</span> +</span><br><span class="line">                <span class="string">&quot;id=&quot;</span> + id +</span><br><span class="line">                <span class="string">&quot;, name=&#x27;&quot;</span> + name + <span class="string">&#x27;\&#x27;&#x27;</span> +</span><br><span class="line">                <span class="string">&quot;, num_c=&quot;</span> + num_c +</span><br><span class="line">                <span class="string">&#x27;&#125;&#x27;</span>;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> <span class="title function_">User</span><span class="params">(<span class="type">int</span> id, String name,NumAll numAll, Num num, CallNum callNum)</span>&#123;</span><br><span class="line">        <span class="built_in">this</span>.id = id;</span><br><span class="line">        <span class="built_in">this</span>.name = name;</span><br><span class="line">        <span class="built_in">this</span>.numAll = numAll;</span><br><span class="line">        <span class="built_in">this</span>.num = num;</span><br><span class="line">        <span class="built_in">this</span>.callNum = callNum;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">work</span><span class="params">()</span>&#123;</span><br><span class="line">        System.out.println(num_c+<span class="string">&quot;号，&quot;</span>+name+<span class="string">&quot; 开始办业务&quot;</span>);</span><br><span class="line">        <span class="keyword">try</span> &#123;</span><br><span class="line">            Thread.sleep(<span class="number">1000</span>);</span><br><span class="line">        &#125; <span class="keyword">catch</span> (InterruptedException e) &#123;</span><br><span class="line">            e.printStackTrace();</span><br><span class="line">        &#125;</span><br><span class="line">        System.out.println(<span class="string">&quot;\t&quot;</span>+num_c+<span class="string">&quot;号，&quot;</span>+name+<span class="string">&quot; 业务完成。&quot;</span>);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="meta">@Override</span></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">run</span><span class="params">()</span> &#123;</span><br><span class="line">        <span class="keyword">synchronized</span> (callNum) &#123;</span><br><span class="line">            <span class="keyword">try</span> &#123;</span><br><span class="line">                <span class="comment">// TODO 取号和补充号码池</span></span><br><span class="line">                <span class="built_in">this</span>.num_c = num.queue.take();</span><br><span class="line">                num.queue.put(numAll.c + <span class="number">1</span>);</span><br><span class="line">                numAll.c++;</span><br><span class="line">                <span class="comment">// TODO 打印取到的号码</span></span><br><span class="line">                System.out.println(<span class="built_in">this</span>);</span><br><span class="line">                <span class="comment">// TODO 进入叫号对列</span></span><br><span class="line">                <span class="keyword">try</span> &#123;</span><br><span class="line">                    CallNum.queueUser.add(<span class="built_in">this</span>);</span><br><span class="line">                &#125; <span class="keyword">catch</span> (Exception e) &#123;</span><br><span class="line">                    System.out.println(<span class="built_in">this</span>.name+<span class="string">&quot;的号码:&quot;</span>+<span class="built_in">this</span>.num_c+<span class="string">&quot;作废，因为今天排队用户已满，明天早点来^_^&quot;</span>);</span><br><span class="line">                &#125;</span><br><span class="line">                <span class="comment">// TODO 等待叫号队列唤醒</span></span><br><span class="line">                callNum.wait();</span><br><span class="line">            &#125;<span class="keyword">catch</span> (InterruptedException e) &#123;</span><br><span class="line">                e.printStackTrace();</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure> 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E5%90%8C%E6%AD%A5/" rel="tag">同步</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E5%B9%B6%E5%8F%91/" rel="tag">并发</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E9%98%9F%E5%88%97/" rel="tag">队列</a></li></ul>

    </footer>
  </div>

   
   
  
</article>

    
    <article
  id="post-Java连接GBase8s执行Statement和PreparedStatement详细示例-md"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2023/08/17/Java%E8%BF%9E%E6%8E%A5GBase8s%E6%89%A7%E8%A1%8CStatement%E5%92%8CPreparedStatement%E8%AF%A6%E7%BB%86%E7%A4%BA%E4%BE%8B-md/"
    >Java连接GBase8s执行Statement和PreparedStatement详细示例.md</a> 
</h2>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2023/08/17/Java%E8%BF%9E%E6%8E%A5GBase8s%E6%89%A7%E8%A1%8CStatement%E5%92%8CPreparedStatement%E8%AF%A6%E7%BB%86%E7%A4%BA%E4%BE%8B-md/" class="article-date">
  <time datetime="2023-08-17T00:02:53.000Z" itemprop="datePublished">2023-08-17</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/Java/">Java</a>
  </div>
   
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <p>存储说明：</p>
<ul>
<li>项目目录： D:\soft\src\Java\java-top-speed\src\main\java\weidb</li>
</ul>
<h3 id="TABLE"><a href="#TABLE" class="headerlink" title="TABLE"></a>TABLE</h3><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">create</span> <span class="keyword">table</span> Goddess (</span><br><span class="line">    id serial <span class="keyword">not</span> <span class="keyword">null</span>,</span><br><span class="line">    user_name <span class="type">char</span>(<span class="number">10</span>),</span><br><span class="line">    sex <span class="type">int</span>,</span><br><span class="line">    age <span class="type">int</span>,</span><br><span class="line">    birthday datetime <span class="keyword">year</span> <span class="keyword">to</span> <span class="keyword">day</span>,</span><br><span class="line">    email <span class="type">varchar</span> (<span class="number">20</span>),</span><br><span class="line">    mobile <span class="type">char</span> (<span class="number">11</span>),</span><br><span class="line">    create_user <span class="type">char</span>(<span class="number">10</span>),</span><br><span class="line">    update_user <span class="type">char</span>(<span class="number">10</span>),</span><br><span class="line">    create_date datetime <span class="keyword">year</span> <span class="keyword">to</span> <span class="keyword">second</span>,</span><br><span class="line">    update_date datetime <span class="keyword">year</span> <span class="keyword">to</span> <span class="keyword">second</span>,</span><br><span class="line">    isDel <span class="type">boolean</span></span><br><span class="line">);</span><br></pre></td></tr></table></figure>

<h3 id="DbUtil-类-连接"><a href="#DbUtil-类-连接" class="headerlink" title="DbUtil 类 连接"></a>DbUtil 类 连接</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> weidb;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> java.sql.*;</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">DbUtil</span> &#123;</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="type">String</span> <span class="variable">DRIVER</span> <span class="operator">=</span> <span class="string">&quot;com.gbasedbt.jdbc.Driver&quot;</span>;</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="type">String</span> <span class="variable">URL</span> <span class="operator">=</span> <span class="string">&quot;jdbc:gbasedbt-sqli://1.1.1.7:60111/appdb:GBASEDBTSERVER=tpcc;CLIENT_LOCALE=zh_cn.utf8;DB_LOCALE=zh_cn.utf8;LOGINTIMEOUT=1000;IFX_LOCK_MODE_WAIT=60;APPENDISAM=true;UPPER_CASE=y;DBDATE=Y4MD&quot;</span>;</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="type">String</span> <span class="variable">USER</span> <span class="operator">=</span> <span class="string">&quot;gbasedbt&quot;</span>;</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="type">String</span> <span class="variable">PASSWORD</span> <span class="operator">=</span> <span class="string">&quot;GBase123!&quot;</span>;</span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">static</span> <span class="type">Connection</span> <span class="variable">conn</span> <span class="operator">=</span> <span class="literal">null</span>;</span><br><span class="line">    <span class="keyword">static</span> &#123;</span><br><span class="line"></span><br><span class="line">        <span class="keyword">try</span> &#123;</span><br><span class="line">            Class.forName(DRIVER);</span><br><span class="line">        &#125; <span class="keyword">catch</span> (ClassNotFoundException e) &#123;</span><br><span class="line">            e.printStackTrace();</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">try</span> &#123;</span><br><span class="line">            conn = DriverManager.getConnection(URL,USER,PASSWORD);</span><br><span class="line">        &#125; <span class="keyword">catch</span> (SQLException e) &#123;</span><br><span class="line">            e.printStackTrace();</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> Connection <span class="title function_">getConnection</span><span class="params">()</span>&#123;</span><br><span class="line">        <span class="keyword">return</span> conn;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h3 id="模型-类-实体类getter-x2F-setter"><a href="#模型-类-实体类getter-x2F-setter" class="headerlink" title="模型   类 实体类getter&#x2F;setter"></a>模型   类 实体类getter&#x2F;setter</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> weidb.model;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> java.text.SimpleDateFormat;</span><br><span class="line"><span class="keyword">import</span> java.util.Date;</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">Goddess</span> &#123;</span><br><span class="line">    <span class="keyword">private</span> Integer id;</span><br><span class="line">    <span class="keyword">private</span> String user_name;</span><br><span class="line">    <span class="keyword">private</span> Integer sex;</span><br><span class="line">    <span class="keyword">private</span> Integer age;</span><br><span class="line">    <span class="keyword">private</span> Date birthday;</span><br><span class="line">    <span class="keyword">private</span> String email;</span><br><span class="line">    <span class="keyword">private</span> String mobile;</span><br><span class="line">    <span class="keyword">private</span> String create_user;</span><br><span class="line">    <span class="keyword">private</span> String update_user;</span><br><span class="line">    <span class="keyword">private</span> Date create_date;</span><br><span class="line">    <span class="keyword">private</span> Date update_date;</span><br><span class="line">    <span class="keyword">private</span> Boolean isDel;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> Integer <span class="title function_">getId</span><span class="params">()</span> &#123;</span><br><span class="line">        <span class="keyword">return</span> id;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">setId</span><span class="params">(Integer id)</span> &#123;</span><br><span class="line">        <span class="built_in">this</span>.id = id;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> String <span class="title function_">getUser_name</span><span class="params">()</span> &#123;</span><br><span class="line">        <span class="keyword">return</span> user_name;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">setUser_name</span><span class="params">(String user_name)</span> &#123;</span><br><span class="line">        <span class="built_in">this</span>.user_name = user_name;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> Integer <span class="title function_">getSex</span><span class="params">()</span> &#123;</span><br><span class="line">        <span class="keyword">return</span> sex;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">setSex</span><span class="params">(Integer sex)</span> &#123;</span><br><span class="line">        <span class="built_in">this</span>.sex = sex;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> Integer <span class="title function_">getAge</span><span class="params">()</span> &#123;</span><br><span class="line">        <span class="keyword">return</span> age;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">setAge</span><span class="params">(Integer age)</span> &#123;</span><br><span class="line">        <span class="built_in">this</span>.age = age;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> Date <span class="title function_">getBirthday</span><span class="params">()</span> &#123;</span><br><span class="line">        <span class="keyword">return</span> birthday;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">setBirthday</span><span class="params">(Date birthday)</span> &#123;</span><br><span class="line">        <span class="built_in">this</span>.birthday = birthday;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> String <span class="title function_">getEmail</span><span class="params">()</span> &#123;</span><br><span class="line">        <span class="keyword">return</span> email;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">setEmail</span><span class="params">(String email)</span> &#123;</span><br><span class="line">        <span class="built_in">this</span>.email = email;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> String <span class="title function_">getMobile</span><span class="params">()</span> &#123;</span><br><span class="line">        <span class="keyword">return</span> mobile;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">setMobile</span><span class="params">(String mobile)</span> &#123;</span><br><span class="line">        <span class="built_in">this</span>.mobile = mobile;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> String <span class="title function_">getCreate_user</span><span class="params">()</span> &#123;</span><br><span class="line">        <span class="keyword">return</span> create_user;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">setCreate_user</span><span class="params">(String create_user)</span> &#123;</span><br><span class="line">        <span class="built_in">this</span>.create_user = create_user;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> String <span class="title function_">getUpdate_user</span><span class="params">()</span> &#123;</span><br><span class="line">        <span class="keyword">return</span> update_user;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">setUpdate_user</span><span class="params">(String update_user)</span> &#123;</span><br><span class="line">        <span class="built_in">this</span>.update_user = update_user;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> Date <span class="title function_">getCreate_date</span><span class="params">()</span> &#123;</span><br><span class="line">        <span class="keyword">return</span> create_date;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">setCreate_date</span><span class="params">(Date create_date)</span> &#123;</span><br><span class="line">        <span class="built_in">this</span>.create_date = create_date;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> Date <span class="title function_">getUpdate_date</span><span class="params">()</span> &#123;</span><br><span class="line">        <span class="keyword">return</span> update_date;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">setUpdate_date</span><span class="params">(Date update_date)</span> &#123;</span><br><span class="line">        <span class="built_in">this</span>.update_date = update_date;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> Boolean <span class="title function_">getDel</span><span class="params">()</span> &#123;</span><br><span class="line">        <span class="keyword">return</span> isDel;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">setDel</span><span class="params">(Boolean del)</span> &#123;</span><br><span class="line">        isDel = del;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="meta">@Override</span></span><br><span class="line">    <span class="keyword">public</span> String <span class="title function_">toString</span><span class="params">()</span> &#123;</span><br><span class="line">        <span class="type">SimpleDateFormat</span> <span class="variable">ft</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">SimpleDateFormat</span>(<span class="string">&quot;yyyy-MM-dd hh:mm:ss&quot;</span>);</span><br><span class="line">        <span class="keyword">return</span> <span class="string">&quot;Goddess&#123;&quot;</span> +</span><br><span class="line">                <span class="string">&quot;id=&quot;</span> + id +</span><br><span class="line">                <span class="string">&quot;, user_name=&#x27;&quot;</span> + user_name + <span class="string">&#x27;\&#x27;&#x27;</span> +</span><br><span class="line">                <span class="string">&quot;, sex=&quot;</span> + sex +</span><br><span class="line">                <span class="string">&quot;, age=&quot;</span> + age +</span><br><span class="line">                <span class="string">&quot;, birthday=&quot;</span> + birthday +</span><br><span class="line">                <span class="string">&quot;, email=&#x27;&quot;</span> + email + <span class="string">&#x27;\&#x27;&#x27;</span> +</span><br><span class="line">                <span class="string">&quot;, mobile=&#x27;&quot;</span> + mobile + <span class="string">&#x27;\&#x27;&#x27;</span> +</span><br><span class="line">                <span class="string">&quot;, create_user=&#x27;&quot;</span> + create_user + <span class="string">&#x27;\&#x27;&#x27;</span> +</span><br><span class="line">                <span class="string">&quot;, update_user=&#x27;&quot;</span> + update_user + <span class="string">&#x27;\&#x27;&#x27;</span> +</span><br><span class="line">                <span class="string">&quot;, create_date=&quot;</span> + ft.format(create_date) +</span><br><span class="line">                <span class="string">&quot;, update_date=&quot;</span> + ft.format(update_date) +</span><br><span class="line">                <span class="string">&quot;, isDel=&quot;</span> + isDel +</span><br><span class="line">                <span class="string">&#x27;&#125;&#x27;</span>;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h3 id="DAO-类-增删改查"><a href="#DAO-类-增删改查" class="headerlink" title="DAO   类  增删改查"></a>DAO   类  增删改查</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> weidb.dao;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> weidb.DbUtil;</span><br><span class="line"><span class="keyword">import</span> weidb.model.Goddess;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> java.sql.*;</span><br><span class="line"><span class="keyword">import</span> java.util.ArrayList;</span><br><span class="line"><span class="keyword">import</span> java.util.List;</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">GoddessDao</span> &#123;</span><br><span class="line">    <span class="comment">//增</span></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">addGoddess</span><span class="params">(Goddess g)</span> <span class="keyword">throws</span> SQLException &#123;</span><br><span class="line">        <span class="type">Connection</span> <span class="variable">conn</span> <span class="operator">=</span> DbUtil.getConnection();</span><br><span class="line">        <span class="type">String</span> <span class="variable">sql</span> <span class="operator">=</span> <span class="string">&quot;INSERT INTO goddess(user_name, sex, age, birthday, email, mobile,create_user, create_date, update_user, update_date, isdel) values (?,?,?,?,?,?,?,current year to second,?,current year to second,?)&quot;</span>;</span><br><span class="line">        <span class="type">PreparedStatement</span> <span class="variable">ps</span> <span class="operator">=</span> conn.prepareStatement(sql);</span><br><span class="line">        ps.setString(<span class="number">1</span>,g.getUser_name());</span><br><span class="line">        ps.setInt(<span class="number">2</span>,g.getSex());</span><br><span class="line">        ps.setInt(<span class="number">3</span>,g.getAge());</span><br><span class="line">        ps.setDate(<span class="number">4</span>,<span class="keyword">new</span> <span class="title class_">Date</span>(g.getBirthday().getTime()));</span><br><span class="line">        ps.setString(<span class="number">5</span>, g.getEmail());</span><br><span class="line">        ps.setString(<span class="number">6</span>,g.getMobile());</span><br><span class="line">        ps.setString(<span class="number">7</span>,g.getCreate_user());</span><br><span class="line">        ps.setString(<span class="number">8</span>,g.getUpdate_user());</span><br><span class="line">        ps.setBoolean(<span class="number">9</span>,g.getDel());</span><br><span class="line">        ps.execute();</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">//删</span></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">delGoddess</span><span class="params">(Integer id)</span> <span class="keyword">throws</span> SQLException&#123;</span><br><span class="line">        <span class="type">Connection</span> <span class="variable">conn</span> <span class="operator">=</span> DbUtil.getConnection();</span><br><span class="line">        <span class="type">String</span> <span class="variable">sql</span> <span class="operator">=</span> <span class="string">&quot;delete from goddess where id=?&quot;</span>;</span><br><span class="line">        <span class="type">PreparedStatement</span> <span class="variable">ps</span> <span class="operator">=</span> conn.prepareStatement(sql);</span><br><span class="line">        ps.setInt(<span class="number">1</span>,id);</span><br><span class="line">        ps.execute();</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">//范围删</span></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">delGoddess</span><span class="params">(Integer id1,Integer id2)</span> <span class="keyword">throws</span> SQLException&#123;</span><br><span class="line">        <span class="type">Connection</span> <span class="variable">conn</span> <span class="operator">=</span> DbUtil.getConnection();</span><br><span class="line">        <span class="type">String</span> <span class="variable">sql</span> <span class="operator">=</span> <span class="string">&quot;delete from goddess where id&gt;=? and id&lt;?&quot;</span>;</span><br><span class="line">        <span class="type">PreparedStatement</span> <span class="variable">ps</span> <span class="operator">=</span> conn.prepareStatement(sql);</span><br><span class="line">        ps.setInt(<span class="number">1</span>,id1);</span><br><span class="line">        ps.setInt(<span class="number">2</span>,id2);</span><br><span class="line">        ps.execute();</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">//改</span></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">updateGoddess</span><span class="params">(Goddess g)</span> <span class="keyword">throws</span> SQLException &#123;</span><br><span class="line">        <span class="type">Connection</span> <span class="variable">conn</span> <span class="operator">=</span> DbUtil.getConnection();</span><br><span class="line">        <span class="type">String</span> <span class="variable">sql</span> <span class="operator">=</span> <span class="string">&quot;UPDATE goddess&quot;</span> +</span><br><span class="line">                <span class="string">&quot; set user_name=?, sex=?, age=?, birthday=?, email=?, mobile=?,&quot;</span> +</span><br><span class="line">                <span class="string">&quot; update_user=?, update_date=current year to second, isDel=? &quot;</span> +</span><br><span class="line">                <span class="string">&quot; where id=?&quot;</span>;</span><br><span class="line">        <span class="type">PreparedStatement</span> <span class="variable">ps</span> <span class="operator">=</span> conn.prepareStatement(sql);</span><br><span class="line">        ps.setString(<span class="number">1</span>, g.getUser_name());</span><br><span class="line">        ps.setInt(<span class="number">2</span>, g.getSex());</span><br><span class="line">        ps.setInt(<span class="number">3</span>, g.getAge());</span><br><span class="line">        ps.setDate(<span class="number">4</span>, <span class="keyword">new</span> <span class="title class_">Date</span>(g.getBirthday().getTime()));</span><br><span class="line">        ps.setString(<span class="number">5</span>, g.getEmail());</span><br><span class="line">        ps.setString(<span class="number">6</span>, g.getMobile());</span><br><span class="line">        ps.setString(<span class="number">7</span>, g.getUpdate_user());</span><br><span class="line">        ps.setBoolean(<span class="number">8</span>, g.getDel());</span><br><span class="line">        ps.setInt(<span class="number">9</span>, g.getId());</span><br><span class="line">        ps.execute();</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">//查全表的2个字段</span></span><br><span class="line">    <span class="keyword">public</span> List&lt;Goddess&gt; <span class="title function_">query</span><span class="params">()</span> <span class="keyword">throws</span> SQLException &#123;</span><br><span class="line">        <span class="type">Connection</span> <span class="variable">conn</span> <span class="operator">=</span> DbUtil.getConnection();</span><br><span class="line">        <span class="type">Statement</span> <span class="variable">stmt</span> <span class="operator">=</span> conn.createStatement();</span><br><span class="line">        <span class="type">String</span> <span class="variable">sql</span> <span class="operator">=</span> <span class="string">&quot;SELECT user_name, age FROM goddess&quot;</span>;</span><br><span class="line">        <span class="type">ResultSet</span> <span class="variable">rs</span> <span class="operator">=</span> stmt.executeQuery(sql);</span><br><span class="line"></span><br><span class="line">        List&lt;Goddess&gt; gs = <span class="keyword">new</span> <span class="title class_">ArrayList</span>&lt;Goddess&gt;();</span><br><span class="line">        <span class="type">Goddess</span> <span class="variable">g</span> <span class="operator">=</span> <span class="literal">null</span>;</span><br><span class="line">        <span class="keyword">while</span> (rs.next())&#123;</span><br><span class="line">            g = <span class="keyword">new</span> <span class="title class_">Goddess</span>();</span><br><span class="line">            g.setUser_name(rs.getString(<span class="string">&quot;user_name&quot;</span>));</span><br><span class="line">            g.setAge(rs.getInt(<span class="string">&quot;age&quot;</span>));</span><br><span class="line">            gs.add(g);</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">return</span> gs;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">//查1条记录</span></span><br><span class="line">    <span class="keyword">public</span> Goddess <span class="title function_">get</span><span class="params">(Integer id)</span> <span class="keyword">throws</span>  SQLException&#123;</span><br><span class="line">        <span class="type">Goddess</span> <span class="variable">g</span> <span class="operator">=</span> <span class="literal">null</span>;</span><br><span class="line">        <span class="type">Connection</span> <span class="variable">conn</span> <span class="operator">=</span> DbUtil.getConnection();</span><br><span class="line">        <span class="type">String</span> <span class="variable">sql</span> <span class="operator">=</span> <span class="string">&quot;select * from goddess where id=?&quot;</span>;</span><br><span class="line">        <span class="type">PreparedStatement</span> <span class="variable">ps</span> <span class="operator">=</span> conn.prepareStatement(sql);</span><br><span class="line">        ps.setInt(<span class="number">1</span>,id);</span><br><span class="line">        <span class="type">ResultSet</span> <span class="variable">rs</span> <span class="operator">=</span> ps.executeQuery();</span><br><span class="line">        <span class="keyword">while</span>(rs.next())&#123;</span><br><span class="line">            g = <span class="keyword">new</span> <span class="title class_">Goddess</span>();</span><br><span class="line">            g.setId(rs.getInt(<span class="string">&quot;id&quot;</span>));</span><br><span class="line">            g.setUser_name(rs.getString(<span class="string">&quot;user_name&quot;</span>));</span><br><span class="line">            g.setAge(rs.getInt(<span class="string">&quot;age&quot;</span>));</span><br><span class="line">            g.setSex(rs.getInt(<span class="string">&quot;sex&quot;</span>));</span><br><span class="line">            g.setBirthday(rs.getDate(<span class="string">&quot;birthday&quot;</span>));</span><br><span class="line">            g.setEmail(rs.getString(<span class="string">&quot;email&quot;</span>));</span><br><span class="line">            g.setMobile(rs.getString(<span class="string">&quot;mobile&quot;</span>));</span><br><span class="line">            g.setCreate_date(rs.getDate(<span class="string">&quot;create_date&quot;</span>));</span><br><span class="line">            g.setCreate_user(rs.getString(<span class="string">&quot;create_user&quot;</span>));</span><br><span class="line">            g.setUpdate_date(rs.getDate(<span class="string">&quot;update_date&quot;</span>));</span><br><span class="line">            g.setUpdate_user(rs.getString(<span class="string">&quot;update_user&quot;</span>));</span><br><span class="line">            g.setDel(rs.getBoolean(<span class="string">&quot;isDel&quot;</span>));</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">return</span> g;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h3 id="Test-类-调用测试"><a href="#Test-类-调用测试" class="headerlink" title="Test  类  调用测试"></a>Test  类  调用测试</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> weidb;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> weidb.dao.GoddessDao;</span><br><span class="line"><span class="keyword">import</span> weidb.model.Goddess;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> java.text.SimpleDateFormat;</span><br><span class="line"><span class="keyword">import</span> java.util.Date;</span><br><span class="line"><span class="keyword">import</span> java.util.List;</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">TestGoddess</span> &#123;</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> <span class="keyword">throws</span> Exception &#123;</span><br><span class="line"></span><br><span class="line">        <span class="type">GoddessDao</span> <span class="variable">goddessDao</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">GoddessDao</span>();</span><br><span class="line"></span><br><span class="line">        <span class="comment">//增</span></span><br><span class="line">        <span class="type">Goddess</span> <span class="variable">g</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">Goddess</span>();</span><br><span class="line">        g.setUser_name(<span class="string">&quot;张三&quot;</span>);</span><br><span class="line">        g.setSex(<span class="number">1</span>);</span><br><span class="line">        g.setAge(<span class="number">36</span>);</span><br><span class="line">        <span class="type">SimpleDateFormat</span> <span class="variable">ft</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">SimpleDateFormat</span>(<span class="string">&quot;yyyy-MM-dd&quot;</span>);</span><br><span class="line">        <span class="type">String</span> <span class="variable">str</span> <span class="operator">=</span> <span class="string">&quot;1990-11-22&quot;</span>;</span><br><span class="line">        <span class="type">Date</span> <span class="variable">date</span> <span class="operator">=</span> ft.parse(str);</span><br><span class="line">        g.setBirthday(date);</span><br><span class="line">        g.setEmail(<span class="string">&quot;wangwei5@gbase.cn&quot;</span>);</span><br><span class="line">        g.setMobile(<span class="string">&quot;18266669999&quot;</span>);</span><br><span class="line">        g.setCreate_user(<span class="string">&quot;admin&quot;</span>);</span><br><span class="line">        g.setUpdate_user(<span class="string">&quot;admin&quot;</span>);</span><br><span class="line">        <span class="type">Date</span> <span class="variable">date1</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">Date</span>();</span><br><span class="line">        g.setCreate_date(date1);</span><br><span class="line">        g.setDel(Boolean.FALSE);</span><br><span class="line">        goddessDao.addGoddess(g);</span><br><span class="line"></span><br><span class="line">        <span class="comment">//删</span></span><br><span class="line">        goddessDao.delGoddess(<span class="number">2</span>);</span><br><span class="line">        goddessDao.delGoddess(<span class="number">3</span>,<span class="number">10</span>);</span><br><span class="line"></span><br><span class="line">        <span class="comment">//改</span></span><br><span class="line">        g.setId(<span class="number">11</span>);</span><br><span class="line">        g.setUser_name(<span class="string">&quot;李四&quot;</span>);</span><br><span class="line">        goddessDao.updateGoddess(g);</span><br><span class="line"></span><br><span class="line">        <span class="comment">//查全表2个字段</span></span><br><span class="line">        List&lt;Goddess&gt; gs = goddessDao.query();</span><br><span class="line">        <span class="keyword">for</span> ( Goddess g1 : gs )&#123;</span><br><span class="line">            System.out.println(g1.getUser_name()+<span class="string">&quot;\t&quot;</span>+g1.getAge());</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        <span class="comment">//查1条</span></span><br><span class="line">        <span class="type">Goddess</span> <span class="variable">g4</span> <span class="operator">=</span> goddessDao.get(<span class="number">1</span>);</span><br><span class="line">        System.out.println(g4);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure> 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/GBase8s/" rel="tag">GBase8s</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Java%E7%A4%BA%E4%BE%8B/" rel="tag">Java示例</a></li></ul>

    </footer>
  </div>

   
   
  
</article>

    
    <article
  id="post-Java连接GBase8s执行Statement和PreparedStatement基本套路和批量提交"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2023/08/17/Java%E8%BF%9E%E6%8E%A5GBase8s%E6%89%A7%E8%A1%8CStatement%E5%92%8CPreparedStatement%E5%9F%BA%E6%9C%AC%E5%A5%97%E8%B7%AF%E5%92%8C%E6%89%B9%E9%87%8F%E6%8F%90%E4%BA%A4/"
    >Java连接GBase8s执行Statement和PreparedStatement基本套路.md</a> 
</h2>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2023/08/17/Java%E8%BF%9E%E6%8E%A5GBase8s%E6%89%A7%E8%A1%8CStatement%E5%92%8CPreparedStatement%E5%9F%BA%E6%9C%AC%E5%A5%97%E8%B7%AF%E5%92%8C%E6%89%B9%E9%87%8F%E6%8F%90%E4%BA%A4/" class="article-date">
  <time datetime="2023-08-16T23:40:34.000Z" itemprop="datePublished">2023-08-17</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/Java/">Java</a>
  </div>
   
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <h3 id="基本套路"><a href="#基本套路" class="headerlink" title="基本套路"></a>基本套路</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> weidb;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> java.sql.Connection;</span><br><span class="line"><span class="keyword">import</span> java.sql.DriverManager;</span><br><span class="line"><span class="keyword">import</span> java.sql.ResultSet;</span><br><span class="line"><span class="keyword">import</span> java.sql.Statement;</span><br><span class="line"><span class="keyword">import</span> java.sql.PreparedStatement;</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">DbUtil</span> &#123;</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="type">String</span> <span class="variable">DRIVER</span> <span class="operator">=</span> <span class="string">&quot;com.gbasedbt.jdbc.Driver&quot;</span>;</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="type">String</span> <span class="variable">URL</span> <span class="operator">=</span> <span class="string">&quot;jdbc:gbasedbt-sqli://1.1.1.7:60111/appdb:GBASEDBTSERVER=tpcc;CLIENT_LOCALE=zh_cn.utf8;DB_LOCALE=zh_cn.utf8;LOGINTIMEOUT=1000;IFX_LOCK_MODE_WAIT=60;APPENDISAM=true;UPPER_CASE=y;DBDATE=Y4MD&quot;</span>;</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="type">String</span> <span class="variable">USER</span> <span class="operator">=</span> <span class="string">&quot;gbasedbt&quot;</span>;</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="type">String</span> <span class="variable">PASSWORD</span> <span class="operator">=</span> <span class="string">&quot;GBase123!&quot;</span>;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> <span class="keyword">throws</span> Exception &#123;</span><br><span class="line">        Class.forName(DRIVER);</span><br><span class="line">        <span class="type">Connection</span> <span class="variable">conn</span> <span class="operator">=</span> DriverManager.getConnection(URL,USER,PASSWORD);</span><br><span class="line">        <span class="type">String</span> <span class="variable">sql1</span> <span class="operator">=</span> <span class="string">&quot;select * from t2 where id &gt; 2&quot;</span>;</span><br><span class="line">        <span class="type">String</span> <span class="variable">sql2</span> <span class="operator">=</span> <span class="string">&quot;select * from t2 where id &gt; ?&quot;</span>;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">        <span class="comment">// 方式1：执行Statement语句</span></span><br><span class="line">        <span class="type">Statement</span> <span class="variable">stmt</span> <span class="operator">=</span> conn.createStatement();</span><br><span class="line">        <span class="type">ResultSet</span> <span class="variable">rs</span> <span class="operator">=</span> stmt.executeQuery(sql1);</span><br><span class="line">        <span class="keyword">while</span> (rs.next())&#123;</span><br><span class="line">            System.out.println(<span class="string">&quot;Statement: &quot;</span>+rs.getInt(<span class="string">&quot;id&quot;</span>)+<span class="string">&quot;名称：&quot;</span>+rs.getString(<span class="string">&quot;name&quot;</span>));</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        <span class="comment">// 方式2：执行PreparedStatement 语句</span></span><br><span class="line">        <span class="type">PreparedStatement</span> <span class="variable">ps</span> <span class="operator">=</span> conn.prepareStatement(sql2);</span><br><span class="line">        ps.setInt(<span class="number">1</span>,<span class="number">2</span>);</span><br><span class="line">        <span class="type">ResultSet</span> <span class="variable">rs1</span> <span class="operator">=</span> ps.executeQuery();</span><br><span class="line">        <span class="keyword">while</span> (rs1.next())&#123;</span><br><span class="line">            System.out.println(<span class="string">&quot;PreparedStatement: &quot;</span>+rs1.getInt(<span class="string">&quot;id&quot;</span>)+<span class="string">&quot;名称：&quot;</span>+rs1.getString(<span class="string">&quot;name&quot;</span>));</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h3 id="批量提交"><a href="#批量提交" class="headerlink" title="批量提交"></a>批量提交</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> weidb;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> java.sql.Connection;</span><br><span class="line"><span class="keyword">import</span> java.sql.PreparedStatement;</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">BatchCommitSqlDemo</span> &#123;</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> <span class="keyword">throws</span> Exception &#123;</span><br><span class="line">        <span class="type">Connection</span> <span class="variable">conn</span> <span class="operator">=</span> DbUtil.getConnection();</span><br><span class="line">        <span class="type">String</span> <span class="variable">sql</span> <span class="operator">=</span> <span class="string">&quot;update goddess set user_name = ? where id = ?&quot;</span>;</span><br><span class="line">        <span class="type">PreparedStatement</span> <span class="variable">ps</span> <span class="operator">=</span> conn.prepareStatement(sql);</span><br><span class="line">        conn.setAutoCommit(<span class="literal">false</span>);</span><br><span class="line">        <span class="keyword">for</span> (<span class="type">int</span> i=<span class="number">1</span>;i&lt;=<span class="number">100</span>;i++)&#123;</span><br><span class="line">            <span class="type">String</span> <span class="variable">name</span> <span class="operator">=</span> String.valueOf(getRandomChar())+getRandomChar();</span><br><span class="line">            ps.setString(<span class="number">1</span>,name);</span><br><span class="line">            ps.setInt(<span class="number">2</span>,i);</span><br><span class="line">            ps.addBatch();</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="type">int</span>[] counts = ps.executeBatch();</span><br><span class="line">        conn.commit();</span><br><span class="line">        <span class="keyword">for</span> (<span class="type">int</span> i=<span class="number">1</span>;i&lt;=<span class="number">100</span>;i++)&#123;</span><br><span class="line">            System.out.println(<span class="string">&quot;语句 &quot;</span>+i+<span class="string">&quot; : 修改了&quot;</span>+ counts[i-<span class="number">1</span>]+<span class="string">&quot;条数据。&quot;</span>);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="type">char</span> <span class="title function_">getRandomChar</span><span class="params">()</span> &#123;</span><br><span class="line">        <span class="keyword">return</span> (<span class="type">char</span>) (<span class="number">0x4e00</span> + (<span class="type">int</span>) (Math.random() * (<span class="number">0x9fa5</span> - <span class="number">0x4e00</span> + <span class="number">1</span>)));</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure>

 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/PreparedStatement/" rel="tag">PreparedStatement</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Statement/" rel="tag">Statement</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/gbase8s/" rel="tag">gbase8s</a></li></ul>

    </footer>
  </div>

   
   
  
</article>

    
    <article
  id="post-GBase8s数据库ACT-SQL统计"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2023/07/03/GBase8s%E6%95%B0%E6%8D%AE%E5%BA%93ACT-SQL%E7%BB%9F%E8%AE%A1/"
    >GBase8s数据库ACT_SQL统计</a> 
</h2>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2023/07/03/GBase8s%E6%95%B0%E6%8D%AE%E5%BA%93ACT-SQL%E7%BB%9F%E8%AE%A1/" class="article-date">
  <time datetime="2023-07-03T06:10:31.000Z" itemprop="datePublished">2023-07-03</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/GBase8s/">GBase8s</a>
  </div>
   
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <h2 id="act脚本"><a href="#act脚本" class="headerlink" title="act脚本"></a>act脚本</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash"></span></span><br><span class="line"><span class="language-bash"><span class="comment"># iact_count.sh  2016.3.24</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">查询Informix IDS活动线程的情况</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">用法: iact.sh [-w] [Interval] [Repeat] [Count]</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">      -w 显示活动线程的sql语句, 每次只显示最频繁的语句</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">      Interval   两次循环的间隔, 缺省1秒</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">      Repeat       重复出现次数，缺省1次</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">      Count     累积循环监控次数，缺省30次</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"></span></span><br><span class="line"><span class="language-bash">wwDATE=$(<span class="built_in">date</span> <span class="string">&#x27;+%Y%m%d-%H%M%S&#x27;</span>)</span> </span><br><span class="line">mkdir -p /tmp/inf_sql/$&#123;wwDATE&#125;</span><br><span class="line">cd /tmp/inf_sql/$&#123;wwDATE&#125;</span><br><span class="line">Interval=1</span><br><span class="line">Count=30</span><br><span class="line">Repeat=2</span><br><span class="line">dLine=10</span><br><span class="line">for i in $*</span><br><span class="line">do</span><br><span class="line">        case $i in</span><br><span class="line">                &quot;-w&quot;)   wFlag=1; dLine=1; shift;;</span><br><span class="line">        esac</span><br><span class="line">done</span><br><span class="line"></span><br><span class="line">tf1=&quot;/tmp/inf_sql/$&#123;wwDATE&#125;/iact1_$$&quot;</span><br><span class="line">tf2=&quot;/tmp/inf_sql/$&#123;wwDATE&#125;/iact2_$$&quot;</span><br><span class="line">tf3=&quot;/tmp/inf_sql/$&#123;wwDATE&#125;/iact3_$$&quot;</span><br><span class="line">tf4=&quot;/tmp/inf_sql/$&#123;wwDATE&#125;/iact4_$$&quot;</span><br><span class="line">tf5=&quot;/tmp/inf_sql/$&#123;wwDATE&#125;/iact5_$$&quot;</span><br><span class="line">tf6=&quot;/tmp/inf_sql/$&#123;wwDATE&#125;/iact6_$$&quot;</span><br><span class="line"></span><br><span class="line">trap &quot;rm -f $tf1 $tf2 $tf3 $tf4 $tf5 $tf6; exit&quot; 1 2 3</span><br><span class="line"></span><br><span class="line">if [ &quot;x$1&quot; != &quot;x&quot; ]; then</span><br><span class="line">        Interval=$1</span><br><span class="line">fi</span><br><span class="line">if [ &quot;x$2&quot; != &quot;x&quot; ]; then</span><br><span class="line">        Repeat=$2</span><br><span class="line">fi</span><br><span class="line">if [ &quot;x$3&quot; != &quot;x&quot; ]; then</span><br><span class="line">        Count=$3</span><br><span class="line">fi</span><br><span class="line">echo &quot;Interval:&quot; $Interval &quot;, &quot;Repeat:&quot; $Repeat &quot;, &quot;Count:&quot; $Count</span><br><span class="line"></span><br><span class="line">cat /dev/null &gt;$tf1</span><br><span class="line">cat /dev/null &gt;$tf2</span><br><span class="line"></span><br><span class="line">i=1</span><br><span class="line"></span><br><span class="line">while [ $i -le $Count ]</span><br><span class="line">do</span><br><span class="line">        &gt;tf.log</span><br><span class="line">        &gt;tf1.log</span><br><span class="line">        &gt;tf2.log</span><br><span class="line">        echo &quot;count=&quot; $i</span><br><span class="line">        onstat -g act | grep -E &#x27;srvinfx|sqlexec&#x27; | awk &#x27;&#123;print $3&#125;&#x27; &gt;$tf3</span><br><span class="line">        cat $tf3 &gt;&gt; $tf4</span><br><span class="line">        grep -f $tf3 $tf4 &gt; $tf1</span><br><span class="line">        grep -vf $tf3 $tf4 &gt; $tf5</span><br><span class="line"></span><br><span class="line">        sort $tf5|uniq -c|awk -v k=$Repeat &#x27;$1 &gt; k &#123;p1=&quot;echo &quot;$2&quot; &gt;&gt; tf.log&quot;;print p1;system(p1)&#125;&#x27;</span><br><span class="line"></span><br><span class="line">        cp $tf1 $tf4</span><br><span class="line"></span><br><span class="line">        echo &quot;count= &quot; $i &quot;------------------------------------------&quot; &gt;&gt; tf_sql.log</span><br><span class="line">        sort $tf4 |uniq -c |sort &gt;&gt; tf_sql.log</span><br><span class="line">        sort $tf4 |uniq -c |sort </span><br><span class="line"></span><br><span class="line"></span><br><span class="line">        sort $tf4|uniq -c|awk -v k=$Repeat &#x27;$1 &gt; k &#123;p1=&quot;echo &quot;$2&quot; &gt;&gt; tf1.log&quot;;system(p1)&#125;&#x27;</span><br><span class="line"></span><br><span class="line">        sort $tf4|uniq -c|awk -v k=$Repeat &#x27;$1 == k &#123;p1=&quot;echo &quot;$2&quot; &gt;&gt; tf2.log&quot;;system(p1)&#125;&#x27;</span><br><span class="line"></span><br><span class="line">        j=`wc tf2.log|awk &#x27;&#123;print $1&#125;&#x27;`</span><br><span class="line">        if [ $j -gt 0 ]; then</span><br><span class="line">            onstat -u|grep -f tf2.log|awk &#x27;&#123;p1 = &quot;onstat -g ses &quot; $3 &quot; &gt;&quot;$1&quot;new.log&quot;;system(p1)&#125;&#x27;</span><br><span class="line">            onstat -u|grep -f tf2.log|awk &#x27;&#123;p1 = &quot;onstat -g ses &quot; $3 &quot; &gt;&quot;$1&quot;.log&quot;;system(p1)&#125;&#x27;        </span><br><span class="line">        fi</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">        j=`wc tf1.log|awk &#x27;&#123;print $1&#125;&#x27;`</span><br><span class="line">        if [ $j -gt 0 ]; then</span><br><span class="line">            onstat -u|grep -f tf1.log|awk &#x27;&#123;p1 = &quot;onstat -g sql &quot; $3 &quot; &gt;&gt;&quot;$1&quot;.log&quot;;system(p1)&#125;&#x27;</span><br><span class="line">        fi</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">        for j in `cat tf.log`</span><br><span class="line">        do</span><br><span class="line">        cat /tmp/inf_sql/$&#123;wwDATE&#125;/$j.log  &gt;&gt; tf_sql.log</span><br><span class="line">        cat /tmp/inf_sql/$&#123;wwDATE&#125;/$&#123;j&#125;new.log  &gt;&gt; tf_sql_new.log</span><br><span class="line">        done</span><br><span class="line"></span><br><span class="line">        sleep $Interval</span><br><span class="line">        i=`expr $i + 1`</span><br><span class="line">done</span><br><span class="line">rm -f $tf1 $tf2 $tf3 $tf4 $tf5 $tf6 tf.log tf1.log tf2.log</span><br><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure>



<h2 id="使用act脚本"><a href="#使用act脚本" class="headerlink" title="使用act脚本"></a>使用act脚本</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">运行</span></span><br><span class="line">sh act.sh |tee -a /tmp/act.log</span><br><span class="line">或者：</span><br><span class="line">sh act.sh 1 1 60 |tee -a /tmp/act.log</span><br></pre></td></tr></table></figure>

<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">查看结果</span></span><br><span class="line">cat /tmp/act.log</span><br><span class="line"></span><br><span class="line">cd /tmp/inf_sql/20230702-021909</span><br><span class="line"></span><br><span class="line">[gbasedbt@wei07 20230702-021909]$ ll</span><br><span class="line">total 20</span><br><span class="line">-rw-rw-r--. 1 gbasedbt gbasedbt 3194 Jul  2 02:19 45de62e8.log       线程每次act时的ses的内容</span><br><span class="line">-rw-rw-r--. 1 gbasedbt gbasedbt 2172 Jul  2 02:19 45de62e8new.log    new线程的act时的ses的内容</span><br><span class="line">-rw-rw-r--. 1 gbasedbt gbasedbt 4856 Jul  2 02:19 tf_sql.log         汇总每个线程</span><br><span class="line">-rw-rw-r--. 1 gbasedbt gbasedbt 2172 Jul  2 02:19 tf_sql_new.log     汇总每个new线程</span><br><span class="line">[gbasedbt@wei07 20230702-021909]$ </span><br><span class="line"></span><br></pre></td></tr></table></figure>

 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/SQL/" rel="tag">SQL</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E6%80%A7%E8%83%BD%E8%B0%83%E4%BC%98/" rel="tag">性能调优</a></li></ul>

    </footer>
  </div>

   
   
  
</article>

    
    <article
  id="post-GBase8s数据库SQL并发量统计"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2023/07/03/GBase8s%E6%95%B0%E6%8D%AE%E5%BA%93SQL%E5%B9%B6%E5%8F%91%E9%87%8F%E7%BB%9F%E8%AE%A1/"
    >GBase8s数据库SQL并发量统计</a> 
</h2>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2023/07/03/GBase8s%E6%95%B0%E6%8D%AE%E5%BA%93SQL%E5%B9%B6%E5%8F%91%E9%87%8F%E7%BB%9F%E8%AE%A1/" class="article-date">
  <time datetime="2023-07-03T06:09:16.000Z" itemprop="datePublished">2023-07-03</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/GBase8s/">GBase8s</a>
  </div>
   
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <h2 id="收集一次ses0，统计当前正在运行的SQL的并发数量"><a href="#收集一次ses0，统计当前正在运行的SQL的并发数量" class="headerlink" title="收集一次ses0，统计当前正在运行的SQL的并发数量"></a>收集一次ses0，统计当前正在运行的SQL的并发数量</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line">onstat -g ses 0 &gt; /tmp/current.ses0</span><br><span class="line">cat /tmp/current.ses0 |awk &#x27;</span><br><span class="line">&#123;</span><br><span class="line">	if ($1~/Current/ &amp;&amp; $2~/SQL/) &#123;; k=1&#125;</span><br><span class="line">	if (NF==0 &amp;&amp; k==1) &#123;; h=NR&#125;</span><br><span class="line">	if (NR==h+1) &#123;; k=0&#125;</span><br><span class="line">	if (k==1 &amp;&amp; $1!~/Current/ &amp;&amp; $2!~/SQL/) &#123;</span><br><span class="line">		for (i=1;i&lt;=NF;i++)&#123; s=s&quot; &quot;$i&#125; </span><br><span class="line"><span class="meta prompt_">		#</span><span class="language-bash"><span class="keyword">if</span> (NF==0) &#123;;<span class="built_in">print</span> s <span class="variable">$0</span>;s=<span class="string">&quot;&quot;</span>&#125;</span>		</span><br><span class="line">		if (NF==0) &#123;A[s]++;s=&quot;&quot;&#125;</span><br><span class="line">		&#125;</span><br><span class="line">&#125;</span><br><span class="line">END &#123;</span><br><span class="line">	for (f in A)&#123;</span><br><span class="line">		print A[f],&quot;===&quot;,f</span><br><span class="line">		s++;</span><br><span class="line">		t=t+A[f];</span><br><span class="line">	&#125;</span><br><span class="line">	printf(&quot;==========================================================\n&quot;);</span><br><span class="line">	print &quot;There are &quot;s&quot; statements and running in &quot;t&quot; threads.&quot;</span><br><span class="line">	printf(&quot;==========================================================\n&quot;);</span><br><span class="line">&#125;&#x27; &gt; /tmp/current0.log</span><br><span class="line">cat  /tmp/current0.log |sort -nrk 1 |awk &#x27;&#123;print &quot;\n\n&quot;,$0&#125;&#x27;</span><br></pre></td></tr></table></figure>



<h2 id="使用"><a href="#使用" class="headerlink" title="使用"></a>使用</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">sh ses0.sh </span><br><span class="line">cat /tmp/current0.log</span><br></pre></td></tr></table></figure> 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/SQL/" rel="tag">SQL</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E6%80%A7%E8%83%BD%E8%B0%83%E4%BC%98/" rel="tag">性能调优</a></li></ul>

    </footer>
  </div>

   
   
  
</article>

    
    <article
  id="post-GBase8s数据库SQL语句耗时跟踪"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2023/07/03/GBase8s%E6%95%B0%E6%8D%AE%E5%BA%93SQL%E8%AF%AD%E5%8F%A5%E8%80%97%E6%97%B6%E8%B7%9F%E8%B8%AA/"
    >GBase8s数据库SQL语句耗时跟踪</a> 
</h2>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2023/07/03/GBase8s%E6%95%B0%E6%8D%AE%E5%BA%93SQL%E8%AF%AD%E5%8F%A5%E8%80%97%E6%97%B6%E8%B7%9F%E8%B8%AA/" class="article-date">
  <time datetime="2023-07-03T06:07:39.000Z" itemprop="datePublished">2023-07-03</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/GBase8s/">GBase8s</a>
  </div>
   
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <h1 id="浦发压测100毫秒以上的SQL统计"><a href="#浦发压测100毫秒以上的SQL统计" class="headerlink" title="浦发压测100毫秒以上的SQL统计"></a>浦发压测100毫秒以上的SQL统计</h1><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">开启trace</span></span><br><span class="line">dbaccess sysadmin &lt;&lt;!</span><br><span class="line">	execute function task(&quot;set sql tracing on&quot;, 20000, 10,&quot;low&quot;,&quot;global&quot;); </span><br><span class="line">!</span><br></pre></td></tr></table></figure>

<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">查看his结果</span></span><br><span class="line">onstat -g his &gt; /tmp/topsql.his</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">查看100毫秒以上的sql</span></span><br><span class="line">dbaccess sysmaster &lt;&lt;!</span><br><span class="line">	unload to /tmp/topsql.100 select sql_runtime,sql_executions,sql_statement </span><br><span class="line">from </span><br><span class="line">    syssqltrace t,</span><br><span class="line">    syssqltrace_iter i</span><br><span class="line">where </span><br><span class="line">	t.sql_id = i.sql_id</span><br><span class="line">	and sql_runtime &gt; 0.100</span><br><span class="line">order by 1 desc;</span><br><span class="line">!</span><br><span class="line"></span><br><span class="line">cat /tmp/topsql.100 |more</span><br></pre></td></tr></table></figure>

<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">关闭trace</span></span><br><span class="line">dbaccess sysadmin &lt;&lt;!</span><br><span class="line">	execute function sysadmin:task(&quot;SET SQL TRACING OFF&quot;);</span><br><span class="line">!</span><br></pre></td></tr></table></figure>









<h1 id="知识："><a href="#知识：" class="headerlink" title="知识："></a>知识：</h1><h2 id="1-开启SQL跟踪"><a href="#1-开启SQL跟踪" class="headerlink" title="1  开启SQL跟踪"></a>1  开启SQL跟踪</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">开启SQL跟踪的参数</span></span><br><span class="line">level = [off, low, med, high]</span><br><span class="line">ntraces = [跟踪的SQL语句的数量]</span><br><span class="line">size = [每个跟踪缓冲区的大小，以KB为单位]</span><br><span class="line">mode = [global, user]</span><br><span class="line">level=low, ntraces=10000, size=10, mode=global</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">Shell&gt; </span><span class="language-bash">su - gbasedbt</span></span><br><span class="line"><span class="meta prompt_">Shell&gt; </span><span class="language-bash">dbaccess sysadmin -</span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">高且全局</span></span><br><span class="line"><span class="meta prompt_">Shell&gt; </span><span class="language-bash">execute <span class="keyword">function</span> task (<span class="string">&quot;set sql tracing on&quot;</span>,30000, <span class="string">&quot;100&quot;</span>,<span class="string">&quot;high&quot;</span>,<span class="string">&quot;global&quot;</span>);<span class="string">&#x27;</span></span> </span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="string">低且具体用户</span></span></span><br><span class="line"><span class="meta prompt_">Shell&gt; </span><span class="language-bash"><span class="string">execute function task(&quot;set sql tracing on&quot;, 20000, 10,&quot;low&quot;,&quot;user&quot;);</span></span> </span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="string">指定会话</span></span></span><br><span class="line"><span class="meta prompt_">Shell&gt; </span><span class="language-bash"><span class="string">execute function task(&quot;set sql user tracing on&quot;,11044);</span></span></span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h2 id="2-执行语句"><a href="#2-执行语句" class="headerlink" title="2  执行语句"></a>2  执行语句</h2><pre><code>    ......或者运行业务。
</code></pre>
<h2 id="3-查询跟踪情况用命令"><a href="#3-查询跟踪情况用命令" class="headerlink" title="3 查询跟踪情况用命令"></a>3 查询跟踪情况用命令</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">onstat -g his</span><br></pre></td></tr></table></figure>

<h2 id="3-查询耗时最多的语句"><a href="#3-查询耗时最多的语句" class="headerlink" title="3 查询耗时最多的语句"></a>3 查询耗时最多的语句</h2><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">select</span> <span class="keyword">first</span> <span class="number">500</span> sql_runtime,sql_executions,sql_statement </span><br><span class="line"><span class="keyword">from</span> </span><br><span class="line">	syssqltrace t,</span><br><span class="line">	syssqltrace_iter i</span><br><span class="line"><span class="keyword">where</span> t.sql_id <span class="operator">=</span> i.sql_id </span><br><span class="line"><span class="keyword">order</span> <span class="keyword">by</span> <span class="number">1</span> <span class="keyword">desc</span>;</span><br></pre></td></tr></table></figure>

<h2 id="4-关闭SQL跟踪"><a href="#4-关闭SQL跟踪" class="headerlink" title="4  关闭SQL跟踪"></a>4  关闭SQL跟踪</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">echo &#x27; execute function sysadmin:task(&quot;SET SQL TRACING OFF&quot;); &#x27; | dbaccess sysadmin</span><br><span class="line"></span><br></pre></td></tr></table></figure>



<p>参数没改，重启trace失效：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment">##################################################################</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">SQL Tracing and EXPLAIN Plan Configuration Parameters</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment">##################################################################</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">EXPLAIN_STAT - Enables (1) or disables (0) including the Query</span> </span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">               Statistics section <span class="keyword">in</span> the EXPLAIN output file</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">SQLTRACE     - Configures SQL tracing. The format is:</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">               SQLTRACE level=(low|med|high),ntraces=&lt;<span class="comment">#&gt;,size=&lt;#&gt;,</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">               mode=(global|user)</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">               Example:</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">               SQLTRACE level=low,ntraces=1000,size=2,mode=global</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment">##################################################################</span></span></span><br><span class="line"></span><br><span class="line">EXPLAIN_STAT 1</span><br><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure>



<table>
<thead>
<tr>
<th>Column</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody><tr>
<td><strong>sql_id</strong></td>
<td>int8</td>
<td>Unique SQL execution ID</td>
</tr>
<tr>
<td><strong>sql_address</strong></td>
<td>int8</td>
<td>Address of the statement in the code block</td>
</tr>
<tr>
<td><strong>sql_sid</strong></td>
<td>int</td>
<td>Database session ID of the user running the SQL statement</td>
</tr>
<tr>
<td><strong>sql_uid</strong></td>
<td>int</td>
<td>User ID of the statement running the SQL</td>
</tr>
<tr>
<td><strong>sql_stmttype</strong></td>
<td>int</td>
<td>Statement type</td>
</tr>
<tr>
<td><strong>sql_stmtname</strong></td>
<td>char(40)</td>
<td>Statement type displayed as a word</td>
</tr>
<tr>
<td><strong>sql_finishtime</strong></td>
<td>int</td>
<td>Time this statement completed (UNIX)</td>
</tr>
<tr>
<td><strong>sql_begintxtime</strong></td>
<td>int</td>
<td>Time this transaction started</td>
</tr>
<tr>
<td><strong>sql_runtime</strong></td>
<td>float</td>
<td>Statement execution time</td>
</tr>
<tr>
<td><strong>sql_pgreads</strong></td>
<td>int</td>
<td>Number of disk reads for this SQL statement</td>
</tr>
<tr>
<td><strong>sql_bfreads</strong></td>
<td>int</td>
<td>Number of buffer reads for this SQL statement</td>
</tr>
<tr>
<td><strong>sql_rdcache</strong></td>
<td>float</td>
<td>Percentage of time the page was read from the buffer pool</td>
</tr>
<tr>
<td><strong>sql_bfidxreads</strong></td>
<td>int</td>
<td>Number of index page buffer reads</td>
</tr>
<tr>
<td><strong>sql_pgwrites</strong></td>
<td>int</td>
<td>Number of pages written to disk</td>
</tr>
<tr>
<td><strong>sql_bfwrites</strong></td>
<td>int</td>
<td>Number of pages modified and returned to the buffer pool</td>
</tr>
<tr>
<td><strong>sql_wrcache</strong></td>
<td>float</td>
<td>Percentage of time a page was written to the buffer pool but not to disk</td>
</tr>
<tr>
<td><strong>sql_lockreq</strong></td>
<td>int</td>
<td>Total number of locks required by this SQL statement</td>
</tr>
<tr>
<td><strong>sql_lockwaits</strong></td>
<td>int</td>
<td>Number of times the SQL statement waited on locks</td>
</tr>
<tr>
<td><strong>sql_lockwttime</strong></td>
<td>float</td>
<td>Time the system waited for locks during SQL statement</td>
</tr>
<tr>
<td><strong>sql_logspace</strong></td>
<td>int</td>
<td>Amount of space the SQL statement used in the logical log</td>
</tr>
<tr>
<td><strong>sql_sorttotal</strong></td>
<td>int</td>
<td>Number of sorts that ran for the statement</td>
</tr>
<tr>
<td><strong>sql_sortdisk</strong></td>
<td>int</td>
<td>Number of sorts that ran on disk</td>
</tr>
<tr>
<td><strong>sql_sortmem</strong></td>
<td>int</td>
<td>Number of sorts that ran in memory</td>
</tr>
<tr>
<td><strong>sql_executions</strong></td>
<td>int</td>
<td>Number of times the SQL statement ran</td>
</tr>
<tr>
<td><strong>sql_totaltime</strong></td>
<td>float</td>
<td>Total amount of time spent running the statement</td>
</tr>
<tr>
<td><strong>sql_avgtime</strong></td>
<td>float</td>
<td>Average amount of time spent running the statement</td>
</tr>
<tr>
<td><strong>sql_maxtime</strong></td>
<td>float</td>
<td>Maximum amount of time spent executing the SQL statement</td>
</tr>
<tr>
<td><strong>sql_numiowaits</strong></td>
<td>int</td>
<td>Number of times an I&#x2F;O operation had to wait</td>
</tr>
<tr>
<td><strong>sql_avgiowaits</strong></td>
<td>float</td>
<td>Average amount of time that the SQL statement had to wait</td>
</tr>
<tr>
<td><strong>sql_totaliowaits</strong></td>
<td>float</td>
<td>Total amount of time that the SQL statement had to wait for I&#x2F;O. This excludes any asynchronous I&#x2F;O.</td>
</tr>
<tr>
<td><strong>sql_rowspersec</strong></td>
<td>float</td>
<td>Average number of rows (per second) produced</td>
</tr>
<tr>
<td><strong>sql_estcost</strong></td>
<td>int</td>
<td>Cost associated with the SQL statement</td>
</tr>
<tr>
<td><strong>sql_estrows</strong></td>
<td>int</td>
<td>Estimated number of rows returned for the SQL statement as predicted by the optimizer</td>
</tr>
<tr>
<td><strong>sql_actualrows</strong></td>
<td>int</td>
<td>Number of rows returned for the SQL statement</td>
</tr>
<tr>
<td><strong>sql_sqlerror</strong></td>
<td>int</td>
<td>SQL error number</td>
</tr>
<tr>
<td><strong>sql_isamerror</strong></td>
<td>int</td>
<td>RSAM&#x2F;ISAM error number</td>
</tr>
<tr>
<td><strong>sql_isollevel</strong></td>
<td>int</td>
<td>Isolation level of the SQL statement.</td>
</tr>
<tr>
<td><strong>sql_sqlmemory</strong></td>
<td>int</td>
<td>Number of bytes needed to execute the SQL statement</td>
</tr>
<tr>
<td><strong>sql_numiterators</strong></td>
<td>int</td>
<td>Number of iterators used by the statement</td>
</tr>
<tr>
<td><strong>sql_database</strong></td>
<td>char(128)</td>
<td>Database name</td>
</tr>
<tr>
<td><strong>sql_numtables</strong></td>
<td>int</td>
<td>Number of tables used in executing the SQL statement</td>
</tr>
<tr>
<td><strong>sql_tablelist</strong></td>
<td>char(4096)</td>
<td>List of table names directly referenced in the SQL statement. If the SQL statement fires triggers that execute statements against other tables, the other tables are not listed.</td>
</tr>
<tr>
<td><strong>sql_statement</strong></td>
<td>char(1600)</td>
<td>SQL statement that ran</td>
</tr>
</tbody></table>
<p>  <strong>syssqltrace</strong>  表提供了详细信息 关于单个 SQL 语句。 </p>
<table>
<thead>
<tr>
<th>列</th>
<th>类型</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td><strong>sql_id</strong></td>
<td>国际8</td>
<td>唯一的 SQL 执行 ID</td>
</tr>
<tr>
<td><strong>sql_address</strong></td>
<td>国际8</td>
<td>代码块中语句的地址</td>
</tr>
<tr>
<td><strong>sql_sid</strong></td>
<td>国际</td>
<td>运行 SQL 的用户的数据库会话 ID 陈述</td>
</tr>
<tr>
<td><strong>sql_uid</strong></td>
<td>国际</td>
<td>运行 SQL 的语句的用户标识</td>
</tr>
<tr>
<td><strong>sql_stmttype</strong></td>
<td>国际</td>
<td>语句类型</td>
</tr>
<tr>
<td><strong>sql_stmtname</strong></td>
<td>字符（40）</td>
<td>显示为单词的语句类型</td>
</tr>
<tr>
<td><strong>sql_finishtime</strong></td>
<td>国际</td>
<td>此语句完成的时间 （UNIX）</td>
</tr>
<tr>
<td><strong>sql_begintxtime</strong></td>
<td>国际</td>
<td>此事务开始的时间</td>
</tr>
<tr>
<td><strong>sql_runtime</strong></td>
<td>浮</td>
<td>语句执行时间</td>
</tr>
<tr>
<td><strong>sql_pgreads</strong></td>
<td>国际</td>
<td>此 SQL 语句的磁盘读取次数</td>
</tr>
<tr>
<td><strong>sql_bfreads</strong></td>
<td>国际</td>
<td>此 SQL 语句的缓冲区读取数</td>
</tr>
<tr>
<td><strong>sql_rdcache</strong></td>
<td>浮</td>
<td>从缓冲区读取页面的时间百分比 池</td>
</tr>
<tr>
<td><strong>sql_bfidxreads</strong></td>
<td>国际</td>
<td>索引页缓冲区读取次数</td>
</tr>
<tr>
<td><strong>sql_pgwrites</strong></td>
<td>国际</td>
<td>写入磁盘的页数</td>
</tr>
<tr>
<td><strong>sql_bfwrites</strong></td>
<td>国际</td>
<td>修改并返回到缓冲区的页数 池</td>
</tr>
<tr>
<td><strong>sql_wrcache</strong></td>
<td>浮</td>
<td>页面写入缓冲区的时间百分比 池但不到磁盘</td>
</tr>
<tr>
<td><strong>sql_lockreq</strong></td>
<td>国际</td>
<td>此 SQL 语句所需的锁总数</td>
</tr>
<tr>
<td><strong>sql_lockwaits</strong></td>
<td>国际</td>
<td>SQL 语句等待锁的次数</td>
</tr>
<tr>
<td><strong>sql_lockwttime</strong></td>
<td>浮</td>
<td>系统在 SQL 语句期间等待锁定的时间</td>
</tr>
<tr>
<td><strong>sql_logspace</strong></td>
<td>国际</td>
<td>SQL 语句在逻辑中使用的空间量 .log</td>
</tr>
<tr>
<td><strong>sql_sorttotal</strong></td>
<td>国际</td>
<td>为语句运行的排序数</td>
</tr>
<tr>
<td><strong>sql_sortdisk</strong></td>
<td>国际</td>
<td>磁盘上运行的排序数</td>
</tr>
<tr>
<td><strong>sql_sortmem</strong></td>
<td>国际</td>
<td>在内存中运行的排序数</td>
</tr>
<tr>
<td><strong>sql_executions</strong></td>
<td>国际</td>
<td>SQL 语句运行的次数</td>
</tr>
<tr>
<td><strong>sql_totaltime</strong></td>
<td>浮</td>
<td>运行语句所花费的总时间</td>
</tr>
<tr>
<td><strong>sql_avgtime</strong></td>
<td>浮</td>
<td>运行语句所花费的平均时间</td>
</tr>
<tr>
<td><strong>sql_maxtime</strong></td>
<td>浮</td>
<td>执行 SQL 所花费的最大时间 陈述</td>
</tr>
<tr>
<td><strong>sql_numiowaits</strong></td>
<td>国际</td>
<td>I&#x2F;O 操作必须等待的次数</td>
</tr>
<tr>
<td><strong>sql_avgiowaits</strong></td>
<td>浮</td>
<td>SQL 语句的平均时间量 等待</td>
</tr>
<tr>
<td><strong>sql_totaliowaits</strong></td>
<td>浮</td>
<td>SQL 语句具有的总时间量 以等待 I&#x2F;O。这不包括任何异步 I&#x2F;O。</td>
</tr>
<tr>
<td><strong>sql_rowspersec</strong></td>
<td>浮</td>
<td>生成的平均行数（每秒）</td>
</tr>
<tr>
<td><strong>sql_estcost</strong></td>
<td>国际</td>
<td>与 SQL 语句关联的成本</td>
</tr>
<tr>
<td><strong>sql_estrows</strong></td>
<td>国际</td>
<td>为 SQL 语句返回的估计行数 正如优化器所预测的那样</td>
</tr>
<tr>
<td><strong>sql_actualrows</strong></td>
<td>国际</td>
<td>为 SQL 语句返回的行数</td>
</tr>
<tr>
<td><strong>sql_sqlerror</strong></td>
<td>国际</td>
<td>SQL 错误号</td>
</tr>
<tr>
<td><strong>sql_isamerror</strong></td>
<td>国际</td>
<td>RSAM&#x2F;ISAM 错误号</td>
</tr>
<tr>
<td><strong>sql_isollevel</strong></td>
<td>国际</td>
<td>SQL 语句的隔离级别。</td>
</tr>
<tr>
<td><strong>sql_sqlmemory</strong></td>
<td>国际</td>
<td>执行 SQL 语句所需的字节数</td>
</tr>
<tr>
<td><strong>sql_numiterators</strong></td>
<td>国际</td>
<td>语句使用的迭代器数</td>
</tr>
<tr>
<td><strong>sql_database</strong></td>
<td>字符（128）</td>
<td>数据库名称</td>
</tr>
<tr>
<td><strong>sql_numtables</strong></td>
<td>国际</td>
<td>用于执行 SQL 语句的表数</td>
</tr>
<tr>
<td><strong>sql_tablelist</strong></td>
<td>字符（4096）</td>
<td>直接引用的表名列表 SQL 语句。如果 SQL 语句触发执行语句的触发器 对于其他表，不会列出其他表。</td>
</tr>
<tr>
<td><strong>sql_statement</strong></td>
<td>字符（1600）</td>
<td>运行的 SQL 语句</td>
</tr>
</tbody></table>
 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/SQL/" rel="tag">SQL</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/trace/" rel="tag">trace</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E6%96%B0%E8%83%BD%E8%B0%83%E4%BC%98/" rel="tag">新能调优</a></li></ul>

    </footer>
  </div>

   
   
  
</article>

    
    <article
  id="post-linux内存管理-内核的shmall和shmmax参数"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2023/07/03/linux%E5%86%85%E5%AD%98%E7%AE%A1%E7%90%86-%E5%86%85%E6%A0%B8%E7%9A%84shmall%E5%92%8Cshmmax%E5%8F%82%E6%95%B0/"
    >linux内存管理--内核的shmall和shmmax参数</a> 
</h2>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2023/07/03/linux%E5%86%85%E5%AD%98%E7%AE%A1%E7%90%86-%E5%86%85%E6%A0%B8%E7%9A%84shmall%E5%92%8Cshmmax%E5%8F%82%E6%95%B0/" class="article-date">
  <time datetime="2023-07-03T06:05:48.000Z" itemprop="datePublished">2023-07-03</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/Linux/">Linux</a>
  </div>
   
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <h3 id="linux-内存管理——内核的shmall-和shmmax-参数"><a href="#linux-内存管理——内核的shmall-和shmmax-参数" class="headerlink" title="linux 内存管理——内核的shmall 和shmmax 参数"></a>linux 内存管理——内核的shmall 和shmmax 参数</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"></span><br><span class="line">1. | 核心参数                                            | 最小建议值（不能小于此值） |</span><br><span class="line">   | --------------------------------------------------- | -------------------------- |</span><br><span class="line">   | SHMMAX (核所允许的最大单个共享内存段的大小(bytes) ) | 4398046511104              |</span><br><span class="line">   | SHMALL (整个系统的全部允许使用的共享内存大小(页) )  | 1073741824                 |</span><br><span class="line">   | SHMMNI (整个系统的共享内存段的最大数目(个)  )       | 4096                       |</span><br><span class="line">   |                                                     |                            |</span><br><span class="line">   | SEMMSL(每个信号量set中信号量最大个数)               | 250                        |</span><br><span class="line">   | SEMMNS(系统中信号量最大个数)                        | 32000                      |</span><br><span class="line">   | SEMOPM(每次semop系统调用允许的信号量最大个数)       | 100                        |</span><br><span class="line">   | SEMMNI(系统信号量set最大个数)                       | 128                        |</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">   #sem其实是semaphores的缩写，查看当前设置</span><br><span class="line">   $ cat /proc/sys/kernel/sem</span><br><span class="line">   250 32000 100 128</span><br><span class="line">   4个数据分别对应</span><br><span class="line">   SEMMSL SEMMNS SEMOPM SEMMNI</span><br><span class="line">   </span><br><span class="line">   SEMMSL</span><br><span class="line">   含义：每个信号量set中信号量最大个数 设置：最小250；对于processes参数设置较大的系统建议设置为processes+10</span><br><span class="line">   </span><br><span class="line">   SEMMNS</span><br><span class="line">   含义：linux系统中信号量最大个数 设置：至少32000；SEMMSL * SEMMNI</span><br><span class="line">   </span><br><span class="line">   SEMOPM</span><br><span class="line">   含义：semop系统调用允许的信号量最大个数 设置：至少100；或者等于SEMMSL</span><br><span class="line">   </span><br><span class="line">   SEMMNI</span><br><span class="line">   含义：linux系统信号量set最大个数 设置：最少128</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">   </span><br></pre></td></tr></table></figure>

<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br><span class="line">201</span><br><span class="line">202</span><br><span class="line">203</span><br><span class="line">204</span><br><span class="line">205</span><br><span class="line">206</span><br><span class="line">207</span><br><span class="line">208</span><br><span class="line">209</span><br><span class="line">210</span><br><span class="line">211</span><br><span class="line">212</span><br><span class="line">213</span><br><span class="line">214</span><br><span class="line">215</span><br><span class="line">216</span><br><span class="line">217</span><br><span class="line">218</span><br><span class="line">219</span><br><span class="line">220</span><br><span class="line">221</span><br><span class="line">222</span><br><span class="line">223</span><br><span class="line">224</span><br><span class="line">225</span><br><span class="line">226</span><br><span class="line">227</span><br><span class="line">228</span><br><span class="line">229</span><br><span class="line">230</span><br><span class="line">231</span><br><span class="line">232</span><br><span class="line">233</span><br><span class="line">234</span><br><span class="line">235</span><br><span class="line">236</span><br><span class="line">237</span><br><span class="line">238</span><br><span class="line">239</span><br><span class="line">240</span><br><span class="line">241</span><br><span class="line">242</span><br><span class="line">243</span><br><span class="line">244</span><br><span class="line">245</span><br><span class="line">246</span><br><span class="line">247</span><br><span class="line">248</span><br><span class="line">249</span><br><span class="line">250</span><br><span class="line">251</span><br><span class="line">252</span><br><span class="line">253</span><br><span class="line">254</span><br><span class="line">255</span><br><span class="line">256</span><br><span class="line">257</span><br><span class="line">258</span><br><span class="line">259</span><br><span class="line">260</span><br><span class="line">261</span><br><span class="line">262</span><br><span class="line">263</span><br><span class="line">264</span><br><span class="line">265</span><br><span class="line">266</span><br><span class="line">267</span><br><span class="line">268</span><br><span class="line">269</span><br><span class="line">270</span><br><span class="line">271</span><br><span class="line">272</span><br><span class="line">273</span><br><span class="line">274</span><br><span class="line">275</span><br><span class="line">276</span><br><span class="line">277</span><br><span class="line">278</span><br><span class="line">279</span><br><span class="line">280</span><br><span class="line">281</span><br><span class="line">282</span><br><span class="line">283</span><br><span class="line">284</span><br><span class="line">285</span><br><span class="line">286</span><br><span class="line">287</span><br><span class="line">288</span><br><span class="line">289</span><br><span class="line">290</span><br><span class="line">291</span><br><span class="line">292</span><br><span class="line">293</span><br><span class="line">294</span><br><span class="line">295</span><br><span class="line">296</span><br><span class="line">297</span><br><span class="line">298</span><br><span class="line">299</span><br><span class="line">300</span><br><span class="line">301</span><br><span class="line">302</span><br><span class="line">303</span><br><span class="line">304</span><br><span class="line">305</span><br><span class="line">306</span><br><span class="line">307</span><br><span class="line">308</span><br><span class="line">309</span><br><span class="line">310</span><br><span class="line">311</span><br><span class="line">312</span><br><span class="line">313</span><br><span class="line">314</span><br><span class="line">315</span><br><span class="line">316</span><br><span class="line">317</span><br><span class="line">318</span><br><span class="line">319</span><br><span class="line">320</span><br><span class="line">321</span><br><span class="line">322</span><br><span class="line">323</span><br><span class="line">324</span><br><span class="line">325</span><br><span class="line">326</span><br><span class="line">327</span><br><span class="line">328</span><br><span class="line">329</span><br><span class="line">330</span><br><span class="line">331</span><br><span class="line">332</span><br><span class="line">333</span><br><span class="line">334</span><br><span class="line">335</span><br><span class="line">336</span><br><span class="line">337</span><br><span class="line">338</span><br><span class="line">339</span><br><span class="line">340</span><br><span class="line">341</span><br><span class="line">342</span><br><span class="line">343</span><br><span class="line">344</span><br><span class="line">345</span><br><span class="line">346</span><br><span class="line">347</span><br><span class="line">348</span><br><span class="line">349</span><br><span class="line">350</span><br><span class="line">351</span><br><span class="line">352</span><br><span class="line">353</span><br><span class="line">354</span><br><span class="line">355</span><br><span class="line">356</span><br><span class="line">357</span><br><span class="line">358</span><br><span class="line">359</span><br><span class="line">360</span><br><span class="line">361</span><br><span class="line">362</span><br><span class="line">363</span><br><span class="line">364</span><br><span class="line">365</span><br><span class="line">366</span><br><span class="line">367</span><br><span class="line">368</span><br><span class="line">369</span><br><span class="line">370</span><br><span class="line">371</span><br><span class="line">372</span><br><span class="line">373</span><br><span class="line">374</span><br><span class="line">375</span><br><span class="line">376</span><br><span class="line">377</span><br><span class="line">378</span><br><span class="line">379</span><br><span class="line">380</span><br><span class="line">381</span><br><span class="line">382</span><br><span class="line">383</span><br><span class="line">384</span><br><span class="line">385</span><br><span class="line">386</span><br><span class="line">387</span><br><span class="line">388</span><br><span class="line">389</span><br><span class="line">390</span><br><span class="line">391</span><br><span class="line">392</span><br><span class="line">393</span><br><span class="line">394</span><br><span class="line">395</span><br><span class="line">396</span><br><span class="line">397</span><br><span class="line">398</span><br><span class="line">399</span><br><span class="line">400</span><br><span class="line">401</span><br><span class="line">402</span><br><span class="line">403</span><br><span class="line">404</span><br><span class="line">405</span><br><span class="line">406</span><br><span class="line">407</span><br><span class="line">408</span><br><span class="line">409</span><br><span class="line">410</span><br><span class="line">411</span><br><span class="line">412</span><br><span class="line">413</span><br><span class="line">414</span><br><span class="line">415</span><br><span class="line">416</span><br><span class="line">417</span><br><span class="line">418</span><br><span class="line">419</span><br><span class="line">420</span><br><span class="line">421</span><br><span class="line">422</span><br><span class="line">423</span><br><span class="line">424</span><br><span class="line">425</span><br><span class="line">426</span><br><span class="line">427</span><br><span class="line">428</span><br><span class="line">429</span><br><span class="line">430</span><br><span class="line">431</span><br><span class="line">432</span><br><span class="line">433</span><br><span class="line">434</span><br><span class="line">435</span><br><span class="line">436</span><br><span class="line">437</span><br><span class="line">438</span><br><span class="line">439</span><br><span class="line">440</span><br><span class="line">441</span><br><span class="line">442</span><br><span class="line">443</span><br><span class="line">444</span><br><span class="line">445</span><br><span class="line">446</span><br><span class="line">447</span><br><span class="line">448</span><br><span class="line">449</span><br><span class="line">450</span><br><span class="line">451</span><br><span class="line">452</span><br><span class="line">453</span><br><span class="line">454</span><br><span class="line">455</span><br><span class="line">456</span><br><span class="line">457</span><br><span class="line">458</span><br><span class="line">459</span><br><span class="line">460</span><br><span class="line">461</span><br><span class="line">462</span><br><span class="line">463</span><br><span class="line">464</span><br><span class="line">465</span><br><span class="line">466</span><br><span class="line">467</span><br><span class="line">468</span><br><span class="line">469</span><br><span class="line">470</span><br><span class="line">471</span><br><span class="line">472</span><br><span class="line">473</span><br><span class="line">474</span><br><span class="line">475</span><br><span class="line">476</span><br><span class="line">477</span><br><span class="line">478</span><br><span class="line">479</span><br><span class="line">480</span><br><span class="line">481</span><br><span class="line">482</span><br><span class="line">483</span><br><span class="line">484</span><br><span class="line">485</span><br><span class="line">486</span><br><span class="line">487</span><br><span class="line">488</span><br><span class="line">489</span><br><span class="line">490</span><br><span class="line">491</span><br><span class="line">492</span><br><span class="line">493</span><br><span class="line">494</span><br><span class="line">495</span><br><span class="line">496</span><br><span class="line">497</span><br><span class="line">498</span><br><span class="line">499</span><br><span class="line">500</span><br><span class="line">501</span><br><span class="line">502</span><br><span class="line">503</span><br><span class="line">504</span><br><span class="line">505</span><br><span class="line">506</span><br><span class="line">507</span><br><span class="line">508</span><br><span class="line">509</span><br><span class="line">510</span><br><span class="line">511</span><br><span class="line">512</span><br><span class="line">513</span><br><span class="line">514</span><br><span class="line">515</span><br><span class="line">516</span><br><span class="line">517</span><br><span class="line">518</span><br><span class="line">519</span><br><span class="line">520</span><br><span class="line">521</span><br><span class="line">522</span><br><span class="line">523</span><br><span class="line">524</span><br><span class="line">525</span><br><span class="line">526</span><br><span class="line">527</span><br><span class="line">528</span><br><span class="line">529</span><br><span class="line">530</span><br><span class="line">531</span><br><span class="line">532</span><br><span class="line">533</span><br><span class="line">534</span><br><span class="line">535</span><br><span class="line">536</span><br><span class="line">537</span><br><span class="line">538</span><br><span class="line">539</span><br><span class="line">540</span><br><span class="line">541</span><br><span class="line">542</span><br><span class="line">543</span><br><span class="line">544</span><br><span class="line">545</span><br><span class="line">546</span><br><span class="line">547</span><br><span class="line">548</span><br><span class="line">549</span><br><span class="line">550</span><br><span class="line">551</span><br></pre></td><td class="code"><pre><span class="line">内核的 shmall 和 shmmax 参数</span><br><span class="line">SHMMAX= 配置了最大的内存segment的大小 ------&gt;这个设置的比SGA_MAX_SIZE大比较好。</span><br><span class="line"></span><br><span class="line">SHMMIN= 最小的内存segment的大小</span><br><span class="line"></span><br><span class="line">SHMMNI= 整个系统的内存segment的总个数</span><br><span class="line"></span><br><span class="line">SHMSEG= 每个进程可以使用的内存segment的最大个数</span><br><span class="line"></span><br><span class="line">配置信号灯（ semphore ）的参数：</span><br><span class="line"></span><br><span class="line">SEMMSL= 每个semphore set里面的semphore数量 -----&gt; 这个设置大于你的process的个数吧，否则你不得不分多个semphore set，好像有process+n之说，我忘了n是几了。</span><br><span class="line"></span><br><span class="line">SEMMNI= 整个系统的semphore set总数</span><br><span class="line"></span><br><span class="line">SEMMNS=整个系统的semphore总数</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">shmall 是全部允许使用的共享内存大小，shmmax 是单个段允许使用的大小。这两个可以设置为内存的 90%。例如 16G 内存，16*1024*1024*1024*90% = 15461882265，shmall 的大小为 15461882265/4k(getconf PAGESIZE可得到) = 3774873。</span><br><span class="line">修改 /etc/sysctl.conf</span><br><span class="line"></span><br><span class="line">kernel.shmmax=15461882265</span><br><span class="line"></span><br><span class="line">kernel.shmall=3774873</span><br><span class="line"></span><br><span class="line">kernel.msgmax=65535</span><br><span class="line"></span><br><span class="line">kernel.msgmnb=65535</span><br><span class="line"></span><br><span class="line">执行 sudo sysctl -p</span><br><span class="line"></span><br><span class="line">可以使用 ipcs -l 看结果。ipcs -u 可以看到实际使用的情况</span><br><span class="line"></span><br><span class="line">========================================================================</span><br><span class="line">linux 内存管理</span><br><span class="line"> </span><br><span class="line">一、前言</span><br><span class="line">本文档针对OOP8生产环境，具体优化策略需要根据实际情况进行调整；本文档将在以下几个方面来阐述如何针对RedHat Enterprise Linux进行性能优化。</span><br><span class="line">1)     Linux Proc文件系统，通过对Proc文件系统进行调整，达到性能优化的目的。</span><br><span class="line">2)     Linux性能诊断工具，介绍如何使用Linux自带的诊断工具进行性能诊断。</span><br><span class="line">加粗斜体表示可以直接运行的命令。</span><br><span class="line">下划线表示文件的内容。</span><br><span class="line">二、/proc/sys/kernel/优化</span><br><span class="line">1)     /proc/sys/kernel/ctrl-alt-del</span><br><span class="line">该文件有一个二进制值，该值控制系统在接收到ctrl+alt+delete按键组合时如何反应。这两个值分别是：</span><br><span class="line">零（0）值，表示捕获ctrl+alt+delete，并将其送至 init 程序；这将允许系统可以安全地关闭和重启，就好象输入shutdown命令一样。</span><br><span class="line">壹（1）值，表示不捕获ctrl+alt+delete，将执行非正常的关闭，就好象直接关闭电源一样。</span><br><span class="line"></span><br><span class="line">缺省设置：0</span><br><span class="line">建议设置：1，防止意外按下ctrl+alt+delete导致系统非正常重启。</span><br><span class="line">2)     proc/sys/kernel/msgmax</span><br><span class="line">该文件指定了从一个进程发送到另一个进程的消息的最大长度（bytes）。进程间的消息传递是在内核的内存中进行的，不会交换到磁盘上，所以如果增加该值，则将增加操作系统所使用的内存数量。</span><br><span class="line"></span><br><span class="line">缺省设置：8192</span><br><span class="line">3)     /proc/sys/kernel/msgmnb</span><br><span class="line">该文件指定一个消息队列的最大长度（bytes）。</span><br><span class="line"></span><br><span class="line">缺省设置：16384</span><br><span class="line">4)     /proc/sys/kernel/msgmni</span><br><span class="line">该文件指定消息队列标识的最大数目，即系统范围内最大多少个消息队列。</span><br><span class="line"></span><br><span class="line">缺省设置：16</span><br><span class="line">5)     /proc/sys/kernel/panic</span><br><span class="line">该文件表示如果发生“内核严重错误（kernel panic）”，则内核在重新引导之前等待的时间（以秒为单位）。</span><br><span class="line">零（0）秒，表示在发生内核严重错误时将禁止自动重新引导。</span><br><span class="line"></span><br><span class="line">缺省设置：0</span><br><span class="line">6)     proc/sys/kernel/shmall</span><br><span class="line">该文件表示在任何给定时刻，系统上可以使用的共享内存的总量（bytes）。</span><br><span class="line"></span><br><span class="line">缺省设置：2097152</span><br><span class="line">7)     /proc/sys/kernel/shmmax</span><br><span class="line">该文件表示内核所允许的最大共享内存段的大小（bytes）。</span><br><span class="line"></span><br><span class="line">缺省设置：33554432</span><br><span class="line">建议设置：物理内存 * 50%</span><br><span class="line"></span><br><span class="line">实际可用最大共享内存段大小=shmmax * 98%，其中大约2%用于共享内存结构。</span><br><span class="line">可以通过设置shmmax，然后执行ipcs -l来验证。</span><br><span class="line">8)     /proc/sys/kernel/shmmni</span><br><span class="line">该文件表示用于整个系统的共享内存段的最大数目（个）。</span><br><span class="line"></span><br><span class="line">缺省设置：4096</span><br><span class="line">9)     /proc/sys/kernel/threads-max</span><br><span class="line">该文件表示内核所能使用的线程的最大数目。</span><br><span class="line"></span><br><span class="line">缺省设置：2048</span><br><span class="line">10) /proc/sys/kernel/sem</span><br><span class="line">该文件用于控制内核信号量，信号量是System VIPC用于进程间通讯的方法。</span><br><span class="line"></span><br><span class="line">建议设置：250 32000 100 128</span><br><span class="line">第一列，表示每个信号集中的最大信号量数目。</span><br><span class="line">第二列，表示系统范围内的最大信号量总数目。</span><br><span class="line">第三列，表示每个信号发生时的最大系统操作数目。</span><br><span class="line">第四列，表示系统范围内的最大信号集总数目。</span><br><span class="line">所以，（第一列）*（第四列）=（第二列）</span><br><span class="line"></span><br><span class="line">以上设置，可以通过执行ipcs -l来验证。</span><br><span class="line">11) 待续。。。</span><br><span class="line">三、/proc/sys/vm/优化</span><br><span class="line">1)     /proc/sys/vm/block_dump</span><br><span class="line">该文件表示是否打开Block Debug模式，用于记录所有的读写及Dirty Block写回动作。</span><br><span class="line"></span><br><span class="line">缺省设置：0，禁用Block Debug模式</span><br><span class="line">2)     /proc/sys/vm/dirty_background_ratio</span><br><span class="line">该文件表示脏数据到达系统整体内存的百分比，此时触发pdflush进程把脏数据写回磁盘。</span><br><span class="line"></span><br><span class="line">缺省设置：10</span><br><span class="line">3)     /proc/sys/vm/dirty_expire_centisecs</span><br><span class="line">该文件表示如果脏数据在内存中驻留时间超过该值，pdflush进程在下一次将把这些数据写回磁盘。</span><br><span class="line"></span><br><span class="line">缺省设置：3000（1/100秒）</span><br><span class="line">4)     /proc/sys/vm/dirty_ratio</span><br><span class="line">该文件表示如果进程产生的脏数据到达系统整体内存的百分比，此时进程自行把脏数据写回磁盘。</span><br><span class="line"></span><br><span class="line">缺省设置：40</span><br><span class="line">5)     /proc/sys/vm/dirty_writeback_centisecs</span><br><span class="line">该文件表示pdflush进程周期性间隔多久把脏数据写回磁盘。</span><br><span class="line"></span><br><span class="line">缺省设置：500（1/100秒）</span><br><span class="line">6)     /proc/sys/vm/vfs_cache_pressure</span><br><span class="line">该文件表示内核回收用于directory和inode cache内存的倾向；缺省值100表示内核将根据pagecache和swapcache，把directory和inode cache保持在一个合理的百分比；降低该值低于100，将导致内核倾向于保留directory和inode cache；增加该值超过100，将导致内核倾向于回收directory和inode cache。</span><br><span class="line"></span><br><span class="line">缺省设置：100</span><br><span class="line">7)     /proc/sys/vm/min_free_kbytes</span><br><span class="line">该文件表示强制Linux VM最低保留多少空闲内存（Kbytes）。</span><br><span class="line"></span><br><span class="line">缺省设置：724（512M物理内存）</span><br><span class="line">8)     /proc/sys/vm/nr_pdflush_threads</span><br><span class="line">该文件表示当前正在运行的pdflush进程数量，在I/O负载高的情况下，内核会自动增加更多的pdflush进程。</span><br><span class="line"></span><br><span class="line">缺省设置：2（只读）</span><br><span class="line">9)     /proc/sys/vm/overcommit_memory</span><br><span class="line">该文件指定了内核针对内存分配的策略，其值可以是0、1、2。</span><br><span class="line">0， 表示内核将检查是否有足够的可用内存供应用进程使用；如果有足够的可用内存，内存申请允许；否则，内存申请失败，并把错误返回给应用进程。</span><br><span class="line">1， 表示内核允许分配所有的物理内存，而不管当前的内存状态如何。</span><br><span class="line">2， 表示内核允许分配超过所有物理内存和交换空间总和的内存（参照overcommit_ratio）。</span><br><span class="line"></span><br><span class="line">缺省设置：0</span><br><span class="line">10) /proc/sys/vm/overcommit_ratio</span><br><span class="line">该文件表示，如果overcommit_memory=2，可以过载内存的百分比，通过以下公式来计算系统整体可用内存。</span><br><span class="line">系统可分配内存=交换空间+物理内存*overcommit_ratio/100</span><br><span class="line"></span><br><span class="line">缺省设置：50（%）</span><br><span class="line">11) /proc/sys/vm/page-cluster</span><br><span class="line">该文件表示在写一次到swap区的时候写入的页面数量，0表示1页，1表示2页，2表示4页。</span><br><span class="line"></span><br><span class="line">缺省设置：3（2的3次方，8页）</span><br><span class="line">12) /proc/sys/vm/swapiness</span><br><span class="line">该文件表示系统进行交换行为的程度，数值（0-100）越高，越可能发生磁盘交换。</span><br><span class="line"></span><br><span class="line">缺省设置：60</span><br><span class="line">13) legacy_va_layout</span><br><span class="line">该文件表示是否使用最新的32位共享内存mmap()系统调用，Linux支持的共享内存分配方式包括mmap()，Posix，System VIPC。</span><br><span class="line">0， 使用最新32位mmap()系统调用。</span><br><span class="line">1， 使用2.4内核提供的系统调用。</span><br><span class="line"></span><br><span class="line">缺省设置：0</span><br><span class="line">14) nr_hugepages</span><br><span class="line">该文件表示系统保留的hugetlb页数。</span><br><span class="line">15) hugetlb_shm_group</span><br><span class="line">该文件表示允许使用hugetlb页创建System VIPC共享内存段的系统组ID。</span><br><span class="line">16) 待续。。。</span><br><span class="line">四、/proc/sys/fs/优化</span><br><span class="line">1)     /proc/sys/fs/file-max</span><br><span class="line">该文件指定了可以分配的文件句柄的最大数目。如果用户得到的错误消息声明由于打开</span><br><span class="line">文件数已经达到了最大值，从而他们不能打开更多文件，则可能需要增加该值。</span><br><span class="line"></span><br><span class="line">缺省设置：4096</span><br><span class="line">建议设置：65536</span><br><span class="line">2)     /proc/sys/fs/file-nr</span><br><span class="line">该文件与 file-max 相关，它有三个值：</span><br><span class="line">已分配文件句柄的数目</span><br><span class="line">已使用文件句柄的数目</span><br><span class="line">文件句柄的最大数目</span><br><span class="line">该文件是只读的，仅用于显示信息。</span><br><span class="line">3)     待续。。。</span><br><span class="line">五、/proc/sys/net/core/优化</span><br><span class="line">该目录下的配置文件主要用来控制内核和网络层之间的交互行为。</span><br><span class="line">1） /proc/sys/net/core/message_burst</span><br><span class="line">写新的警告消息所需的时间（以 1/10 秒为单位）；在这个时间内系统接收到的其它警告消息会被丢弃。这用于防止某些企图用消息“淹没”系统的人所使用的拒绝服务（Denial of Service）攻击。</span><br><span class="line"></span><br><span class="line">缺省设置：50（5秒）</span><br><span class="line">2） /proc/sys/net/core/message_cost</span><br><span class="line">该文件表示写每个警告消息相关的成本值。该值越大，越有可能忽略警告消息。</span><br><span class="line"></span><br><span class="line">缺省设置：5</span><br><span class="line">3） /proc/sys/net/core/netdev_max_backlog</span><br><span class="line">该文件表示在每个网络接口接收数据包的速率比内核处理这些包的速率快时，允许送到队列的数据包的最大数目。</span><br><span class="line"></span><br><span class="line">缺省设置：300</span><br><span class="line">4） /proc/sys/net/core/optmem_max</span><br><span class="line">该文件表示每个套接字所允许的最大缓冲区的大小。</span><br><span class="line"></span><br><span class="line">缺省设置：10240</span><br><span class="line">5） /proc/sys/net/core/rmem_default</span><br><span class="line">该文件指定了接收套接字缓冲区大小的缺省值（以字节为单位）。</span><br><span class="line"></span><br><span class="line">缺省设置：110592</span><br><span class="line">6） /proc/sys/net/core/rmem_max</span><br><span class="line">该文件指定了接收套接字缓冲区大小的最大值（以字节为单位）。</span><br><span class="line"></span><br><span class="line">缺省设置：131071</span><br><span class="line">7） /proc/sys/net/core/wmem_default</span><br><span class="line">该文件指定了发送套接字缓冲区大小的缺省值（以字节为单位）。</span><br><span class="line"></span><br><span class="line">缺省设置：110592</span><br><span class="line">8） /proc/sys/net/core/wmem_max</span><br><span class="line">该文件指定了发送套接字缓冲区大小的最大值（以字节为单位）。</span><br><span class="line"></span><br><span class="line">缺省设置：131071</span><br><span class="line">9） 待续。。。</span><br><span class="line">六、/proc/sys/net/ipv4/优化</span><br><span class="line">1)     /proc/sys/net/ipv4/ip_forward</span><br><span class="line">该文件表示是否打开IP转发。</span><br><span class="line">0，禁止</span><br><span class="line">1，转发</span><br><span class="line"></span><br><span class="line">缺省设置：0</span><br><span class="line">2)     /proc/sys/net/ipv4/ip_default_ttl</span><br><span class="line">该文件表示一个数据报的生存周期（Time To Live），即最多经过多少路由器。</span><br><span class="line"></span><br><span class="line">缺省设置：64</span><br><span class="line">增加该值会降低系统性能。</span><br><span class="line">3)     /proc/sys/net/ipv4/ip_no_pmtu_disc</span><br><span class="line">该文件表示在全局范围内关闭路径MTU探测功能。</span><br><span class="line"></span><br><span class="line">缺省设置：0</span><br><span class="line">4)     /proc/sys/net/ipv4/route/min_pmtu</span><br><span class="line">该文件表示最小路径MTU的大小。</span><br><span class="line"></span><br><span class="line">缺省设置：552</span><br><span class="line">5)     /proc/sys/net/ipv4/route/mtu_expires</span><br><span class="line">该文件表示PMTU信息缓存多长时间（秒）。</span><br><span class="line"></span><br><span class="line">缺省设置：600（秒）</span><br><span class="line">6)     /proc/sys/net/ipv4/route/min_adv_mss</span><br><span class="line">该文件表示最小的MSS（Maximum Segment Size）大小，取决于第一跳的路由器MTU。</span><br><span class="line"></span><br><span class="line">缺省设置：256（bytes）</span><br><span class="line">6.1 IP Fragmentation</span><br><span class="line">1)     /proc/sys/net/ipv4/ipfrag_low_thresh/proc/sys/net/ipv4/ipfrag_low_thresh</span><br><span class="line">两个文件分别表示用于重组IP分段的内存分配最低值和最高值，一旦达到最高内存分配值，其它分段将被丢弃，直到达到最低内存分配值。</span><br><span class="line"></span><br><span class="line">缺省设置：196608（ipfrag_low_thresh）</span><br><span class="line">262144（ipfrag_high_thresh）</span><br><span class="line">2)     /proc/sys/net/ipv4/ipfrag_time</span><br><span class="line">该文件表示一个IP分段在内存中保留多少秒。</span><br><span class="line"></span><br><span class="line">缺省设置：30（秒）</span><br><span class="line">6.2 INET Peer Storage</span><br><span class="line">1)     /proc/sys/net/ipv4/inet_peer_threshold</span><br><span class="line">INET对端存储器某个合适值，当超过该阀值条目将被丢弃。该阀值同样决定生存</span><br><span class="line">时间以及废物收集通过的时间间隔。条目越多，存活期越低，GC 间隔越短。</span><br><span class="line"></span><br><span class="line">缺省设置：65664</span><br><span class="line">2)     /proc/sys/net/ipv4/inet_peer_minttl</span><br><span class="line">条目的最低存活期。在重组端必须要有足够的碎片(fragment)存活期。这个最低</span><br><span class="line">存活期必须保证缓冲池容积是否少于 inet_peer_threshold。该值以 jiffies为</span><br><span class="line">单位测量。</span><br><span class="line"></span><br><span class="line">缺省设置：120</span><br><span class="line">3)     /proc/sys/net/ipv4/inet_peer_maxttl</span><br><span class="line">条目的最大存活期。在此期限到达之后，如果缓冲池没有耗尽压力的话(例如：缓</span><br><span class="line">冲池中的条目数目非常少)，不使用的条目将会超时。该值以 jiffies为单位测量。</span><br><span class="line"></span><br><span class="line">缺省设置：600</span><br><span class="line">4)     /proc/sys/net/ipv4/inet_peer_gc_mintime</span><br><span class="line">废物收集(GC)通过的最短间隔。这个间隔会影响到缓冲池中内存的高压力。 该值</span><br><span class="line">以 jiffies为单位测量。</span><br><span class="line"></span><br><span class="line">缺省设置：10</span><br><span class="line"></span><br><span class="line">2006-10-31 16:33 清水飘萍</span><br><span class="line">5)     /proc/sys/net/ipv4/inet_peer_gc_maxtime</span><br><span class="line">废物收集(GC)通过的最大间隔，这个间隔会影响到缓冲池中内存的低压力。 该值</span><br><span class="line">以 jiffies为单位测量。</span><br><span class="line"></span><br><span class="line">缺省设置：120</span><br><span class="line">6.3 TCP Variables</span><br><span class="line">1)     /proc/sys/net/ipv4/tcp_syn_retries</span><br><span class="line">该文件表示本机向外发起TCP SYN连接超时重传的次数，不应该高于255；该值仅仅针对外出的连接，对于进来的连接由tcp_retries1控制。</span><br><span class="line"></span><br><span class="line">缺省设置：5</span><br><span class="line">2)     /proc/sys/net/ipv4/tcp_keepalive_probes</span><br><span class="line">该文件表示丢弃TCP连接前，进行最大TCP保持连接侦测的次数。保持连接仅在</span><br><span class="line">SO_KEEPALIVE套接字选项被打开时才被发送。</span><br><span class="line"></span><br><span class="line">缺省设置：9（次）</span><br><span class="line">3)     /proc/sys/net/ipv4/tcp_keepalive_time</span><br><span class="line">该文件表示从不再传送数据到向连接上发送保持连接信号之间所需的秒数。</span><br><span class="line"></span><br><span class="line">缺省设置：7200（2小时）</span><br><span class="line">4)     /proc/sys/net/ipv4/tcp_keepalive_intvl</span><br><span class="line">该文件表示发送TCP探测的频率，乘以tcp_keepalive_probes表示断开没有相应的TCP连接的时间。</span><br><span class="line"></span><br><span class="line">缺省设置：75（秒）</span><br><span class="line">5)     /proc/sys/net/ipv4/tcp_retries1</span><br><span class="line">该文件表示放弃回应一个TCP连接请求前进行重传的次数。</span><br><span class="line"></span><br><span class="line">缺省设置：3</span><br><span class="line">6)     /proc/sys/net/ipv4/tcp_retries2</span><br><span class="line">该文件表示放弃在已经建立通讯状态下的一个TCP数据包前进行重传的次数。</span><br><span class="line"></span><br><span class="line">缺省设置：15</span><br><span class="line">7)     /proc/sys/net/ipv4/tcp_orphan_retries</span><br><span class="line">在近端丢弃TCP连接之前，要进行多少次重试。默认值是 7 个，相当于 50秒–</span><br><span class="line">16分钟，视 RTO 而定。如果您的系统是负载很大的web服务器，那么也许需</span><br><span class="line">要降低该值，这类 sockets 可能会耗费大量的资源。另外参考</span><br><span class="line">tcp_max_orphans。</span><br><span class="line">8)     /proc/sys/net/ipv4/tcp_fin_timeout</span><br><span class="line">对于本端断开的socket连接，TCP保持在FIN-WAIT-2状态的时间。对方可能</span><br><span class="line">会断开连接或一直不结束连接或不可预料的进程死亡。默认值为 60 秒。过去在</span><br><span class="line">2.2版本的内核中是 180 秒。您可以设置该值，但需要注意，如果您的机器为负</span><br><span class="line">载很重的web服务器，您可能要冒内存被大量无效数据报填满的风险，</span><br><span class="line">FIN-WAIT-2 sockets 的危险性低于 FIN-WAIT-1，因为它们最多只吃 1.5K</span><br><span class="line">的内存，但是它们存在时间更长。另外参考 tcp_max_orphans。</span><br><span class="line"></span><br><span class="line">缺省设置：60（秒）</span><br><span class="line">9)     /proc/sys/net/ipv4/tcp_max_tw_buckets</span><br><span class="line">系统在同时所处理的最大timewait sockets 数目。如果超过此数的话，</span><br><span class="line">time-wait socket 会被立即砍除并且显示警告信息。之所以要设定这个限制，纯</span><br><span class="line">粹为了抵御那些简单的 DoS 攻击，千万不要人为的降低这个限制，不过，如果</span><br><span class="line">网络条件需要比默认值更多，则可以提高它(或许还要增加内存)。</span><br><span class="line"></span><br><span class="line">缺省设置：180000</span><br><span class="line">10) /proc/sys/net/ipv4/tcp_tw_recyle</span><br><span class="line">打开快速 TIME-WAIT sockets 回收。除非得到技术专家的建议或要求，请不要随</span><br><span class="line">意修改这个值。</span><br><span class="line"></span><br><span class="line">缺省设置：0</span><br><span class="line">11) /proc/sys/net/ipv4/tcp_tw_reuse</span><br><span class="line">该文件表示是否允许重新应用处于TIME-WAIT状态的socket用于新的TCP连接。</span><br><span class="line"></span><br><span class="line">缺省设置：0</span><br><span class="line">12) /proc/sys/net/ipv4/tcp_max_orphans</span><br><span class="line">系统所能处理不属于任何进程的TCP sockets最大数量。假如超过这个数量，那</span><br><span class="line">么不属于任何进程的连接会被立即reset，并同时显示警告信息。之所以要设定这</span><br><span class="line">个限制，纯粹为了抵御那些简单的 DoS 攻击，千万不要依赖这个或是人为的降</span><br><span class="line">低这个限制。</span><br><span class="line"></span><br><span class="line">缺省设置：8192</span><br><span class="line">13) /proc/sys/net/ipv4/tcp_abort_on_overflow</span><br><span class="line">当守护进程太忙而不能接受新的连接，就向对方发送reset消息，默认值是false。</span><br><span class="line">这意味着当溢出的原因是因为一个偶然的猝发，那么连接将恢复状态。只有在你确</span><br><span class="line">信守护进程真的不能完成连接请求时才打开该选项，该选项会影响客户的使用。</span><br><span class="line"></span><br><span class="line">缺省设置：０</span><br><span class="line">14) /proc/sys/net/ipv4/tcp_syncookies</span><br><span class="line">该文件表示是否打开TCP同步标签(syncookie)，内核必须打开了 CONFIG_SYN_COOKIES项进行编译。 同步标签(syncookie)可以防止一个套接字在有过多试图连接到达时引起过载。</span><br><span class="line"></span><br><span class="line">缺省设置：0</span><br><span class="line">15) /proc/sys/net/ipv4/tcp_stdurg</span><br><span class="line">使用 TCP urg pointer 字段中的主机请求解释功能。大部份的主机都使用老旧的</span><br><span class="line">BSD解释，因此如果您在 Linux 打开它，或会导致不能和它们正确沟通。</span><br><span class="line"></span><br><span class="line">缺省设置：0</span><br><span class="line">16) /proc/sys/net/ipv4/tcp_max_syn_backlog</span><br><span class="line">对于那些依然还未获得客户端确认的连接请求，需要保存在队列中最大数目。对于</span><br><span class="line">超过 128Mb 内存的系统，默认值是 1024，低于 128Mb 的则为 128。如果</span><br><span class="line">服务器经常出现过载，可以尝试增加这个数字。警告！假如您将此值设为大于</span><br><span class="line">1024，最好修改 include/net/tcp.h 里面的 TCP_SYNQ_HSIZE，以保持</span><br><span class="line">TCP_SYNQ_HSIZE*16 0)或者bytes-bytes/2^(-tcp_adv_win_scale)(如</span><br><span class="line">果tcp_adv_win_scale 128Mb 32768-610000)则系统将忽略所有发送给自己</span><br><span class="line">的ICMP ECHO请求或那些广播地址的请求。</span><br><span class="line"></span><br><span class="line">缺省设置：1024</span><br><span class="line">17) /proc/sys/net/ipv4/tcp_window_scaling</span><br><span class="line">该文件表示设置tcp/ip会话的滑动窗口大小是否可变。参数值为布尔值，为1时表示可变，为0时表示不可变。tcp/ip通常使用的窗口最大可达到 65535 字节，对于高速网络，该值可能太小，这时候如果启用了该功能，可以使tcp/ip滑动窗口大小增大数个数量级，从而提高数据传输的能力。</span><br><span class="line"></span><br><span class="line">缺省设置：1</span><br><span class="line">18) /proc/sys/net/ipv4/tcp_sack</span><br><span class="line">该文件表示是否启用有选择的应答（Selective Acknowledgment），这可以通过有选择地应答乱序接收到的报文来提高性能（这样可以让发送者只发送丢失的报文段）；（对于广域网通信来说）这个选项应该启用，但是这会增加对 CPU 的占用。</span><br><span class="line"></span><br><span class="line">缺省设置：1</span><br><span class="line">19) /proc/sys/net/ipv4/tcp_timestamps</span><br><span class="line">该文件表示是否启用以一种比超时重发更精确的方法（请参阅 RFC 1323）来启用对 RTT 的计算；为了实现更好的性能应该启用这个选项。</span><br><span class="line"></span><br><span class="line">缺省设置：1</span><br><span class="line">20) /proc/sys/net/ipv4/tcp_fack</span><br><span class="line">该文件表示是否打开FACK拥塞避免和快速重传功能。</span><br><span class="line"></span><br><span class="line">缺省设置：1</span><br><span class="line">21) /proc/sys/net/ipv4/tcp_dsack</span><br><span class="line">该文件表示是否允许TCP发送“两个完全相同”的SACK。</span><br><span class="line"></span><br><span class="line">缺省设置：1</span><br><span class="line">22) /proc/sys/net/ipv4/tcp_ecn</span><br><span class="line">该文件表示是否打开TCP的直接拥塞通告功能。</span><br><span class="line"></span><br><span class="line">缺省设置：0</span><br><span class="line">23) /proc/sys/net/ipv4/tcp_reordering</span><br><span class="line">该文件表示TCP流中重排序的数据报最大数量。</span><br><span class="line"></span><br><span class="line">缺省设置：3</span><br><span class="line">24) /proc/sys/net/ipv4/tcp_retrans_collapse</span><br><span class="line">该文件表示对于某些有bug的打印机是否提供针对其bug的兼容性。</span><br><span class="line"></span><br><span class="line">缺省设置：1</span><br><span class="line">25) /proc/sys/net/ipv4/tcp_wmem</span><br><span class="line">该文件包含3个整数值，分别是：min，default，max</span><br><span class="line">Min：为TCP socket预留用于发送缓冲的内存最小值。每个TCP socket都可以使用它。</span><br><span class="line">Default：为TCP socket预留用于发送缓冲的内存数量，默认情况下该值会影响其它协议使用的net.core.wmem中default的 值，一般要低于net.core.wmem中default的值。</span><br><span class="line">Max：为TCP socket预留用于发送缓冲的内存最大值。该值不会影响net.core.wmem_max，今天选择参数SO_SNDBUF则不受该值影响。默认值为128K。</span><br><span class="line"></span><br><span class="line">缺省设置：4096 16384 131072</span><br><span class="line">26) /proc/sys/net/ipv4/tcp_rmem</span><br><span class="line">该文件包含3个整数值，分别是：min，default，max</span><br><span class="line">Min：为TCP socket预留用于接收缓冲的内存数量，即使在内存出现紧张情况下TCP socket都至少会有这么多数量的内存用于接收缓冲。</span><br><span class="line">Default：为TCP socket预留用于接收缓冲的内存数量，默认情况下该值影响其它协议使用的 net.core.wmem中default的值。该值决定了在tcp_adv_win_scale、tcp_app_win和tcp_app_win的 默认值情况下，TCP 窗口大小为65535。</span><br><span class="line">Max：为TCP socket预留用于接收缓冲的内存最大值。该值不会影响 net.core.wmem中max的值，今天选择参数 SO_SNDBUF则不受该值影响。</span><br><span class="line"></span><br><span class="line">缺省设置：4096 87380 174760</span><br><span class="line">27) /proc/sys/net/ipv4/tcp_mem</span><br><span class="line">该文件包含3个整数值，分别是：low，pressure，high</span><br><span class="line">Low：当TCP使用了低于该值的内存页面数时，TCP不会考虑释放内存。</span><br><span class="line">Pressure：当TCP使用了超过该值的内存页面数量时，TCP试图稳定其内存使用，进入pressure模式，当内存消耗低于low值时则退出pressure状态。</span><br><span class="line">High：允许所有tcp sockets用于排队缓冲数据报的页面量。</span><br><span class="line">一般情况下这些值是在系统启动时根据系统内存数量计算得到的。</span><br><span class="line"></span><br><span class="line">缺省设置：24576 32768 49152</span><br><span class="line">28) /proc/sys/net/ipv4/tcp_app_win</span><br><span class="line">该文件表示保留max(window/2^tcp_app_win, mss)数量的窗口由于应用缓冲。当为0时表示不需要缓冲。</span><br><span class="line"></span><br><span class="line">缺省设置：31</span><br><span class="line">29) /proc/sys/net/ipv4/tcp_adv_win_scale</span><br><span class="line">该文件表示计算缓冲开销bytes/2^tcp_adv_win_scale(如果tcp_adv_win_scale &gt;; 0)或者bytes-bytes/2^(-tcp_adv_win_scale)(如果tcp_adv_win_scale &lt;= 0）。</span><br><span class="line"></span><br><span class="line">缺省设置：2</span><br><span class="line">6.4 IP Variables</span><br><span class="line">1)     /proc/sys/net/ipv4/ip_local_port_range</span><br><span class="line">该文件表示TCP／UDP协议打开的本地端口号。</span><br><span class="line"></span><br><span class="line">缺省设置：1024 4999</span><br><span class="line">建议设置：32768 61000</span><br><span class="line">2)     /proc/sys/net/ipv4/ip_nonlocal_bind</span><br><span class="line">该文件表示是否允许进程邦定到非本地地址。</span><br><span class="line"></span><br><span class="line">缺省设置：0</span><br><span class="line">3)     /proc/sys/net/ipv4/ip_dynaddr</span><br><span class="line">该参数通常用于使用拨号连接的情况，可以使系统动能够立即改变ip包的源地址为该ip地址，同时中断原有的tcp对话而用新地址重新发出一个syn请求 包，开始新的tcp对话。在使用ip欺骗时，该参数可以立即改变伪装地址为新的ip地址。该文件表示是否允许动态地址，如果该值非0，表示允许；如果该值 大于1，内核将通过log记录动态地址重写信息。</span><br><span class="line"></span><br><span class="line">缺省设置：0</span><br><span class="line">4)     /proc/sys/net/ipv4/icmp_echo_ignore_all/proc/sys/net/ipv4/icmp_echo_ignore_broadcasts</span><br><span class="line">该文件表示内核是否忽略所有的ICMP ECHO请求，或忽略广播和多播请求。</span><br><span class="line">0， 响应请求</span><br><span class="line">1， 忽略请求</span><br><span class="line"></span><br><span class="line">缺省设置：０</span><br><span class="line">建议设置：1</span><br><span class="line">5)     /proc/sys/net/ipv4/icmp_ratelimit</span><br><span class="line">6)     /proc/sys/net/ipv4/icmp_ratemask</span><br><span class="line">7)     /proc/sys/net/ipv4/icmp_ignore_bogus_error_reponses</span><br><span class="line">某些路由器违背RFC1122标准，其对广播帧发送伪造的响应来应答。这种违背行</span><br><span class="line">为通常会被以告警的方式记录在系统日志中。如果该选项设置为True，内核不会</span><br><span class="line">记录这种警告信息。</span><br><span class="line"></span><br><span class="line">缺省设置：0</span><br><span class="line">8)     /proc/sys/net/ipv4/igmp_max_memberships</span><br><span class="line">该文件表示多播组中的最大成员数量。</span><br><span class="line"></span><br><span class="line">缺省设置：20</span><br><span class="line">6.5 Other Configuration</span><br><span class="line">1)     /proc/sys/net/ipv4/conf/*/accept_redirects</span><br><span class="line">如果主机所在的网段中有两个路由器，你将其中一个设置成了缺省网关，但是该网关</span><br><span class="line">在收到你的ip包时发现该ip包必须经过另外一个路由器，这时这个路由器就会给你</span><br><span class="line">发一个所谓的“重定向”icmp包，告诉将ip包转发到另外一个路由器。参数值为布尔</span><br><span class="line">值，1表示接收这类重定向icmp 信息，0表示忽略。在充当路由器的linux主机上缺</span><br><span class="line">省值为0，在一般的linux主机上缺省值为1。建议将其改为0以消除安全性隐患。</span><br><span class="line">2)     /proc/sys/net/ipv4/*/accept_source_route</span><br><span class="line">是否接受含有源路由信息的ip包。参数值为布尔值，1表示接受，0表示不接受。在</span><br><span class="line">充当网关的linux主机上缺省值为1，在一般的linux主机上缺省值为0。从安全性角</span><br><span class="line">度出发，建议关闭该功能。</span><br><span class="line">3)     /proc/sys/net/ipv4/*/secure_redirects</span><br><span class="line">其实所谓的“安全重定向”就是只接受来自网关的“重定向”icmp包。该参数就是</span><br><span class="line">用来设置“安全重定向”功能的。参数值为布尔值，1表示启用，0表示禁止，缺省值</span><br><span class="line">为启用。</span><br><span class="line">4)     /proc/sys/net/ipv4/*/proxy_arp</span><br><span class="line">设置是否对网络上的arp包进行中继。参数值为布尔值，1表示中继，0表示忽略，</span><br><span class="line">缺省值为0。该参数通常只对充当路由器的linux主机有用。</span><br><span class="line">七、性能优化策略</span><br><span class="line">7.1 基本优化</span><br><span class="line">1)     关闭后台守护进程</span><br><span class="line">系统安装完后，系统会默认启动一些后台守护进程，有些进程并不是必需的；因此，关闭这些进程可以节省一部分物理内存消耗。以root身份登录系统，运行ntsysv，选中如下进程：</span><br><span class="line">iptables</span><br><span class="line">network</span><br><span class="line">syslog</span><br><span class="line">random</span><br><span class="line">apmd</span><br><span class="line">xinetd</span><br><span class="line">vsftpd</span><br><span class="line">crond</span><br><span class="line">local</span><br><span class="line">修改完后，重新启动系统。</span><br><span class="line">如此，系统将仅仅启动选中的这些守护进程。</span><br><span class="line">2)     减少终端连接数</span><br><span class="line">系统默认启动6个终端，而实际上只需启动3个即可；以root身份登录系统，运行vi /etc/inittab，修改成如下：</span><br><span class="line"># Run gettys in standard runlevels</span><br><span class="line">1:2345:respawn:/sbin/mingetty tty1</span><br><span class="line">2:2345:respawn:/sbin/mingetty tty2</span><br><span class="line">3:2345:respawn:/sbin/mingetty tty3</span><br><span class="line">#4:2345:respawn:/sbin/mingetty tty4</span><br><span class="line">#5:2345:respawn:/sbin/mingetty tty5</span><br><span class="line">#6:2345:respawn:/sbin/mingetty tty6</span><br><span class="line">如上所述，注释掉4、5、6终端。</span><br><span class="line">3)     待续。。。</span><br><span class="line">7.2 网络优化</span><br><span class="line">1)     优化系统套接字缓冲区</span><br><span class="line">net.core.rmem_max=16777216</span><br><span class="line">net.core.wmem_max=16777216</span><br><span class="line">2)     优化TCP接收／发送缓冲区</span><br><span class="line">net.ipv4.tcp_rmem=4096 87380 16777216</span><br><span class="line">net.ipv4.tcp_wmem=4096 65536 16777216</span><br><span class="line">3)     优化网络设备接收队列</span><br><span class="line">net.core.netdev_max_backlog=3000</span><br><span class="line">4)     关闭路由相关功能</span><br><span class="line">net.ipv4.conf.lo.accept_source_route=0</span><br><span class="line">net.ipv4.conf.all.accept_source_route=0</span><br><span class="line">net.ipv4.conf.eth0.accept_source_route=0</span><br><span class="line">net.ipv4.conf.default.accept_source_route=0</span><br><span class="line"></span><br><span class="line">net.ipv4.conf.lo.accept_redirects=0</span><br><span class="line">net.ipv4.conf.all.accept_redirects=0</span><br><span class="line">net.ipv4.conf.eth0.accept_redirects=0</span><br><span class="line">net.ipv4.conf.default.accept_redirects=0</span><br><span class="line"></span><br><span class="line">net.ipv4.conf.lo.secure_redirects=0</span><br><span class="line">net.ipv4.conf.all.secure_redirects=0</span><br><span class="line">net.ipv4.conf.eth0.secure_redirects=0</span><br><span class="line">net.ipv4.conf.default.secure_redirects=0</span><br><span class="line"></span><br><span class="line">net.ipv4.conf.lo.send_redirects=0</span><br><span class="line">net.ipv4.conf.all.send_redirects=0</span><br><span class="line">net.ipv4.conf.eth0.send_redirects=0</span><br><span class="line">net.ipv4.conf.default.send_redirects=0</span><br><span class="line">5)     优化TCP协议栈</span><br><span class="line">打开TCP SYN cookie选项，有助于保护服务器免受SyncFlood攻击。</span><br><span class="line">net.ipv4.tcp_syncookies=1</span><br><span class="line"></span><br><span class="line">打开TIME-WAIT套接字重用功能，对于存在大量连接的Web服务器非常有效。</span><br><span class="line">net.ipv4.tcp_tw_recyle=1</span><br><span class="line">net.ipv4.tcp_tw_reuse=1</span><br><span class="line"></span><br><span class="line">减少处于FIN-WAIT-2连接状态的时间，使系统可以处理更多的连接。</span><br><span class="line">net.ipv4.tcp_fin_timeout=30</span><br><span class="line"></span><br><span class="line">减少TCP KeepAlive连接侦测的时间，使系统可以处理更多的连接。</span><br><span class="line">net.ipv4.tcp_keepalive_time=1800</span><br><span class="line"></span><br><span class="line">增加TCP SYN队列长度，使系统可以处理更多的并发连接。</span><br><span class="line">net.ipv4.tcp_max_syn_backlog=8192</span><br></pre></td></tr></table></figure>

 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E5%86%85%E6%A0%B8%E5%8F%82%E6%95%B0/" rel="tag">内核参数</a></li></ul>

    </footer>
  </div>

   
   
  
</article>

    
    <article
  id="post-GBase8s数据库Docker镜像的获取与定制使用"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2023/06/23/GBase8s%E6%95%B0%E6%8D%AE%E5%BA%93Docker%E9%95%9C%E5%83%8F%E7%9A%84%E8%8E%B7%E5%8F%96%E4%B8%8E%E5%AE%9A%E5%88%B6%E4%BD%BF%E7%94%A8/"
    >GBase8s数据库Docker镜像的获取与定制使用</a> 
</h2>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2023/06/23/GBase8s%E6%95%B0%E6%8D%AE%E5%BA%93Docker%E9%95%9C%E5%83%8F%E7%9A%84%E8%8E%B7%E5%8F%96%E4%B8%8E%E5%AE%9A%E5%88%B6%E4%BD%BF%E7%94%A8/" class="article-date">
  <time datetime="2023-06-23T05:18:58.000Z" itemprop="datePublished">2023-06-23</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/GBase8s/">GBase8s</a>
  </div>
   
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <h1 id="GBase8s数据库Docker镜像的获取与定制使用"><a href="#GBase8s数据库Docker镜像的获取与定制使用" class="headerlink" title="GBase8s数据库Docker镜像的获取与定制使用"></a>GBase8s数据库Docker镜像的获取与定制使用</h1><h2 id="获取镜像"><a href="#获取镜像" class="headerlink" title="获取镜像"></a>获取镜像</h2><p>下载链接：<a target="_blank" rel="noopener" href="https://pan.baidu.com/s/1r_seJxToWUvKkYL_5Ae3IA">https://pan.baidu.com/s/1r_seJxToWUvKkYL_5Ae3IA</a><br>提取码：6789</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">gunzip gbase330-1.3.tar.gz</span><br><span class="line"></span><br><span class="line">docker import gbase330-1.3.tar gbase330:1.3</span><br></pre></td></tr></table></figure>



<h2 id="收集需求"><a href="#收集需求" class="headerlink" title="收集需求"></a>收集需求</h2><p>用户申请gbase8s数据库的云主机时，需要提供  cpu&#x2F;内存&#x2F;磁盘 三个必要参数。</p>
<ul>
<li><p>cpu  :  变量  dbcpu     单位 （个）</p>
</li>
<li><p>mem:  变量  dbmem  单位 （MB）</p>
</li>
<li><p>disk： 变量  dbdsk     单位  （GB）</p>
</li>
</ul>
<p>用户还可以提供 实例名&#x2F;实例端口 两个可选参数，如果这两个参数不提供默认是 gbase01 和 9088 。</p>
<ul>
<li>实例名     ： 变量   dbser  </li>
<li>监听端口 ： 变量    dbpot</li>
</ul>
<h2 id="创建容器"><a href="#创建容器" class="headerlink" title="创建容器"></a>创建容器</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker run -e dbcpu=4 -e dbmem=2048 -e dbdsk=10 -e dbser=gbase02 -e dbpot=9002 --name gbase02 -itd gbase330:1.3 /bin/bash</span><br></pre></td></tr></table></figure>



<h2 id="初始化数据库"><a href="#初始化数据库" class="headerlink" title="初始化数据库"></a>初始化数据库</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker exec -it gbase02 /opt/dbinit0.sh</span><br></pre></td></tr></table></figure>



<h2 id="启停数据库"><a href="#启停数据库" class="headerlink" title="启停数据库"></a>启停数据库</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">docker exec -it gbase02 su - gbasedbt -c &quot;oninit -vy&quot;</span><br><span class="line">docker exec -it gbase02 su - gbasedbt -c &quot;onmode -ky&quot;</span><br></pre></td></tr></table></figure>



<h2 id="停数据库容器"><a href="#停数据库容器" class="headerlink" title="停数据库容器"></a>停数据库容器</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">docker exec -it gbase02 su - gbasedbt -c &quot;onmode -ky&quot;</span><br><span class="line">docker stop  gbase02</span><br></pre></td></tr></table></figure>



<h2 id="启数据库容器"><a href="#启数据库容器" class="headerlink" title="启数据库容器"></a>启数据库容器</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">docker start gbase02</span><br><span class="line">docker exec -it gbase02 su - gbasedbt -c &quot;oninit -vy&quot;</span><br></pre></td></tr></table></figure>



<h2 id="连接数据库"><a href="#连接数据库" class="headerlink" title="连接数据库"></a>连接数据库</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">--== GBase 8s Information for this install ==--</span><br><span class="line">GBASEDBTSERVER  : gbase02</span><br><span class="line">GBASEDBTDIR     : /opt/gbase</span><br><span class="line">USER HOME       : /home/gbasedbt</span><br><span class="line">DBSPACE DIR     : /home/gbasedbt/data</span><br><span class="line">IP ADDRESS      : 0.0.0.0</span><br><span class="line">PORT NUMBER     : 9002</span><br><span class="line">DB_LOCALE      : zh_CN.utf8</span><br><span class="line">CLIENT_LOCALE  : zh_CN.utf8</span><br><span class="line"></span><br><span class="line">JDBC URL        : jdbc:gbasedbt-sqli://0.0.0.0:9002/testdb:GBASEDBTSERVER=gbase02;DB_LOCALE=zh_CN.utf8;CLIENT_LOCALE=zh_CN.utf8;IFX_LOCK_MODE_WAIT=10</span><br><span class="line">JDBC USERNAME   : gbasedbt</span><br><span class="line">JDBC PASSWORD   : GBase123!</span><br><span class="line"></span><br><span class="line">备注：  数据库会监听Docker上的所有IP的指定端口，生产环境Docker一般用桥接模式，请换成您的真实IP地址。</span><br></pre></td></tr></table></figure>

 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Docker/" rel="tag">Docker</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E5%AE%B9%E5%99%A8/" rel="tag">容器</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E8%87%AA%E7%A0%94/" rel="tag">自研</a></li></ul>

    </footer>
  </div>

   
   
  
</article>

    
    <article
  id="post-自制工具：GBase8s关机状态下导出某个表的全量数据"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2023/06/15/%E8%87%AA%E5%88%B6%E5%B7%A5%E5%85%B7%EF%BC%9AGBase8s%E5%85%B3%E6%9C%BA%E7%8A%B6%E6%80%81%E4%B8%8B%E5%AF%BC%E5%87%BA%E6%9F%90%E4%B8%AA%E8%A1%A8%E7%9A%84%E5%85%A8%E9%87%8F%E6%95%B0%E6%8D%AE/"
    >自制工具：GBase8s关机状态下导出某个表的全量数据</a> 
</h2>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2023/06/15/%E8%87%AA%E5%88%B6%E5%B7%A5%E5%85%B7%EF%BC%9AGBase8s%E5%85%B3%E6%9C%BA%E7%8A%B6%E6%80%81%E4%B8%8B%E5%AF%BC%E5%87%BA%E6%9F%90%E4%B8%AA%E8%A1%A8%E7%9A%84%E5%85%A8%E9%87%8F%E6%95%B0%E6%8D%AE/" class="article-date">
  <time datetime="2023-06-15T12:29:14.000Z" itemprop="datePublished">2023-06-15</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/GBase8s/">GBase8s</a>
  </div>
   
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <h1 id="自制工具：GBase8s关机状态下导出某个表的全量数据"><a href="#自制工具：GBase8s关机状态下导出某个表的全量数据" class="headerlink" title="自制工具：GBase8s关机状态下导出某个表的全量数据"></a>自制工具：GBase8s关机状态下导出某个表的全量数据</h1><h2 id="问题："><a href="#问题：" class="headerlink" title="问题："></a>问题：</h2><pre><code>    在生产环境中，如果遇到没用备份，同时数据库库实例也无法启动，的情况。 如何抢救表的数据呢？
</code></pre>
<h2 id="答案："><a href="#答案：" class="headerlink" title="答案："></a>答案：</h2><pre><code>    此文可以解答这个问题，通过这个工具，我们可以实现表数据的抢救。
</code></pre>
<h2 id="前提："><a href="#前提：" class="headerlink" title="前提："></a>前提：</h2><ol>
<li>我们知道要抢救的数据库名称：例如 db1</li>
<li>我们知道要抢救的表名称：例如 tab01</li>
<li>我们知道要抢救表的表结构语句：例如：create table tab01 (id int,name char(9) ,addr varchar(9));</li>
<li>我们实例不能正常启动，但是我们这个表的数据页并没有备格式化或损坏。</li>
</ol>
<h2 id="使用介绍："><a href="#使用介绍：" class="headerlink" title="使用介绍："></a>使用介绍：</h2><h3 id="数据抢救–流程概述："><a href="#数据抢救–流程概述：" class="headerlink" title="数据抢救–流程概述："></a>数据抢救–流程概述：</h3><ul>
<li><p>在无法启动的坏实例上：（老生产环境）</p>
<ul>
<li><p>读取磁盘提取到tab01表所在的partation页和数据页。</p>
</li>
<li><p>通过dd下载这些页。</p>
</li>
</ul>
</li>
<li><p>在新的GBase8s实例上：（手术台）</p>
<ul>
<li><p>在新的GBase8s数据库实例上创建空表tab01。</p>
</li>
<li><p>dd修改空表的partation页使之和老实例基本上一致。</p>
</li>
<li><p>dd修改空表的数据页使之和老实例基本上一致。</p>
</li>
<li><p>使用unload select语句导出表的全量数据。</p>
</li>
</ul>
</li>
<li><p>在新的生产实例上：（新生产环境）</p>
<ul>
<li><p>创建表。</p>
</li>
<li><p>导数数据。</p>
</li>
</ul>
</li>
</ul>
<h3 id="先准备好“手术刀”："><a href="#先准备好“手术刀”：" class="headerlink" title="先准备好“手术刀”："></a>先准备好“手术刀”：</h3><h4 id="手术刀工具介绍："><a href="#手术刀工具介绍：" class="headerlink" title="手术刀工具介绍："></a>手术刀工具介绍：</h4><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">[gbasedbt@wei07 GBase8sL3]$ cp a b</span><br><span class="line">[gbasedbt@wei07 GBase8sL3]$ dd1 a b 1 2 2 3 1 1</span><br><span class="line">if=a of=b skip=1 seed=2 bs=2 count=3 itw=1 otw=1</span><br><span class="line">[gbasedbt@wei07 GBase8sL3]$</span><br><span class="line">[gbasedbt@wei07 GBase8sL3]$ cat a</span><br><span class="line">aaaaabbbbb</span><br><span class="line">cccccddddd</span><br><span class="line">[gbasedbt@wei07 GBase8sL3]$ cat b</span><br><span class="line">1111aaabbb</span><br><span class="line">3333344444</span><br><span class="line">[gbasedbt@wei07 GBase8sL3]$</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>注明：dd1 工具随文档发放源码，可以自行领取。</p>
<pre><code>        dd1 工具是我自己写的用来做patch的工具，因为系统默认的dd工具会有不可控情况，所以自编了一个dd1工具。
</code></pre>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;stdio.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;stdlib.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;string.h&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="type">void</span> <span class="title function_">dddd</span><span class="params">(<span class="type">char</span> *ifile, <span class="type">char</span> *ofile, <span class="type">int</span> skip, <span class="type">int</span> seek, <span class="type">int</span> bs, <span class="type">int</span> count, <span class="type">int</span> itw, <span class="type">int</span> otw)</span> </span><br><span class="line">&#123;</span><br><span class="line">    FILE *i;</span><br><span class="line">    FILE *o;</span><br><span class="line">    i = fopen(ifile,<span class="string">&quot;r&quot;</span>);</span><br><span class="line">    o = fopen(ofile,<span class="string">&quot;r+&quot;</span>);</span><br><span class="line">    <span class="keyword">if</span> ( i == <span class="literal">NULL</span> )&#123;</span><br><span class="line">        <span class="built_in">printf</span>(<span class="string">&quot;打开文件时出错：%s\n&quot;</span>, ifile);</span><br><span class="line">        <span class="built_in">exit</span>(<span class="number">1</span>);</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">if</span> ( o == <span class="literal">NULL</span> )&#123;</span><br><span class="line">        <span class="built_in">printf</span>(<span class="string">&quot;打开文件时出错：%s\n&quot;</span>, ofile);</span><br><span class="line">        <span class="built_in">exit</span>(<span class="number">1</span>);</span><br><span class="line">    &#125;</span><br><span class="line">    </span><br><span class="line">    <span class="comment">//初始化文件指针位置</span></span><br><span class="line">    <span class="keyword">if</span> ( itw == <span class="number">-1</span> ) &#123;   <span class="comment">//如果itw为-1,那么跳到文件末尾，skip将视作为负数</span></span><br><span class="line">        fseek(i,<span class="number">0</span>,SEEK_END);</span><br><span class="line">        skip=skip*(<span class="number">-1</span>);</span><br><span class="line">    &#125; <span class="keyword">else</span> <span class="keyword">if</span> ( itw == <span class="number">1</span>) &#123;</span><br><span class="line">        fseek(i,<span class="number">0</span>,SEEK_SET);</span><br><span class="line">    &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">        <span class="built_in">printf</span>(<span class="string">&quot;入参itw不符合要求(1/-1)：%d&quot;</span>, itw);</span><br><span class="line">        <span class="built_in">exit</span>(<span class="number">1</span>);</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">if</span> ( otw == <span class="number">-1</span> ) &#123;   <span class="comment">//如果otw为-1,那么跳到文件末尾，seek将视作为负数</span></span><br><span class="line">        fseek(o,<span class="number">0</span>,SEEK_END);</span><br><span class="line">        seek=seek*(<span class="number">-1</span>);</span><br><span class="line">    &#125; <span class="keyword">else</span> <span class="keyword">if</span> ( otw == <span class="number">1</span> ) &#123;</span><br><span class="line">        fseek(o,<span class="number">0</span>,SEEK_SET);</span><br><span class="line">    &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">        <span class="built_in">printf</span>(<span class="string">&quot;入参otw不符合要求(1/-1)：%d&quot;</span>, otw);</span><br><span class="line">        <span class="built_in">exit</span>(<span class="number">1</span>);</span><br><span class="line">    &#125;</span><br><span class="line">    </span><br><span class="line">    <span class="comment">//读取字节：</span></span><br><span class="line">    <span class="type">char</span> inbyte[count*bs];</span><br><span class="line">    fseek(i,skip*bs,SEEK_CUR);</span><br><span class="line">    fread(inbyte,<span class="keyword">sizeof</span>(inbyte),<span class="number">1</span>,i);</span><br><span class="line">    </span><br><span class="line">    <span class="comment">//patch字节：</span></span><br><span class="line">    fseek(o,seek*bs,SEEK_CUR);</span><br><span class="line">    fwrite(inbyte,<span class="keyword">sizeof</span>(inbyte),<span class="number">1</span>,o);</span><br><span class="line">    </span><br><span class="line">    fclose(i);</span><br><span class="line">    fclose(o);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="type">int</span> <span class="title function_">main</span><span class="params">(<span class="type">int</span> canshunum,<span class="type">char</span> *canshu[])</span>&#123;</span><br><span class="line">    <span class="type">char</span> ifile[<span class="number">100</span>] ;</span><br><span class="line">    <span class="type">char</span> ofile[<span class="number">100</span>] ;</span><br><span class="line">    <span class="built_in">strcpy</span>(ifile,canshu[<span class="number">1</span>]); </span><br><span class="line">    <span class="built_in">strcpy</span>(ofile,canshu[<span class="number">2</span>]); </span><br><span class="line">    <span class="type">int</span> skip = atoi(canshu[<span class="number">3</span>]);</span><br><span class="line">    <span class="type">int</span> seek = atoi(canshu[<span class="number">4</span>]);</span><br><span class="line">    <span class="type">int</span> bs = atoi(canshu[<span class="number">5</span>]);</span><br><span class="line">    <span class="type">int</span> count = atoi(canshu[<span class="number">6</span>]);</span><br><span class="line">    <span class="type">int</span> itw  = atoi(canshu[<span class="number">7</span>]);</span><br><span class="line">    <span class="type">int</span> otw  = atoi(canshu[<span class="number">8</span>]);</span><br><span class="line">    <span class="built_in">printf</span>(<span class="string">&quot;if=%s of=%s skip=%d seed=%d bs=%d count=%d itw=%d otw=%d\n&quot;</span>,ifile, ofile, skip, seek,  bs, count,  itw, otw);</span><br><span class="line">    dddd(ifile, ofile, skip, seek,  bs, count,  itw, otw);</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure>







<h3 id="数据抢救–例子："><a href="#数据抢救–例子：" class="headerlink" title="数据抢救–例子："></a>数据抢救–例子：</h3><h4 id="老生产环境：创建测试库和测试表"><a href="#老生产环境：创建测试库和测试表" class="headerlink" title="老生产环境：创建测试库和测试表"></a>老生产环境：创建测试库和测试表</h4><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">w01_init_env.sh</span></span><br><span class="line">onmode -ky</span><br><span class="line">onclean -ky</span><br><span class="line">rm -fr /opt/data/*</span><br><span class="line">touch /opt/data/rootchk</span><br><span class="line">touch /opt/data/plogdbs</span><br><span class="line">touch /opt/data/llogdbs</span><br><span class="line">touch /opt/data/tmpdbs01</span><br><span class="line">touch /opt/data/tmpdbs02</span><br><span class="line">touch /opt/data/tmpdbs03</span><br><span class="line">touch /opt/data/tmpdbs04</span><br><span class="line">touch /opt/data/datachk01</span><br><span class="line">chmod 660 /opt/data/*</span><br><span class="line"></span><br><span class="line">sed -i &#x27;s/^FULL_DISK_INIT.*$/FULL_DISK_INIT 1/&#x27; $GBASEDBTDIR/etc/$ONCONFIG</span><br><span class="line">sed -i &#x27;s/^PHYSFILE.*$/#PHYSFILE/&#x27; $GBASEDBTDIR/etc/$ONCONFIG</span><br><span class="line">sed -i &#x27;s/^LOGFILES.*$/LOGFILES/&#x27; $GBASEDBTDIR/etc/$ONCONFIG</span><br><span class="line">sed -i &#x27;s/^LOGSIZE.*$/LOGSIZE/&#x27; $GBASEDBTDIR/etc/$ONCONFIG</span><br><span class="line">oninit -ivy</span><br><span class="line"></span><br><span class="line">onspaces -c -d plogdbs -p /opt/data/plogdbs -o 0 -s 10000 </span><br><span class="line">onspaces -c -d llogdbs -p /opt/data/llogdbs -o 0 -s 10000 </span><br><span class="line">onspaces -c -d tmpdbs01 -p /opt/data/tmpdbs01 -o 0 -s 10000 -t</span><br><span class="line">onspaces -c -d tmpdbs02 -p /opt/data/tmpdbs02 -o 0 -s 10000 -t</span><br><span class="line">onspaces -c -d tmpdbs03 -p /opt/data/tmpdbs03 -o 0 -s 10000 -t</span><br><span class="line">onspaces -c -d tmpdbs04 -p /opt/data/tmpdbs04 -o 0 -s 10000 -t</span><br><span class="line">onspaces -c -d datadbs01 -p /opt/data/datachk01 -o 0 -k 16 -s `echo &quot;25600*16&quot;|bc`</span><br><span class="line"></span><br><span class="line">sleep 1;</span><br><span class="line">onmode -c</span><br><span class="line">ontape -s -L 0 -t /dev/null</span><br><span class="line"></span><br><span class="line">dbaccess - - &lt;&lt;!</span><br><span class="line">    create database db01 in datadbs01;</span><br><span class="line">    select hex(partnum),tabname from systables;</span><br><span class="line">!</span><br><span class="line"></span><br><span class="line">sleep 1;</span><br><span class="line"></span><br><span class="line">i=2;</span><br><span class="line">while [ $i -le 200 ]</span><br><span class="line">do</span><br><span class="line">dbaccess db01 &lt;&lt;!</span><br><span class="line">    create table t$&#123;i&#125;(id int,name varchar(20), addr char(10)) </span><br><span class="line">    extent size 64 next size 128;</span><br><span class="line">!</span><br><span class="line">let i=$i+1</span><br><span class="line">done</span><br><span class="line"></span><br><span class="line">echo &quot;insert into t6 values(1,&#x27;abcdef&#x27;,&#x27;abcdef1&#x27;); &quot; |dbaccess db01</span><br><span class="line">echo &quot;insert into t6 values(2,&#x27;abcdef&#x27;,&#x27;abcdef2&#x27;); &quot; |dbaccess db01</span><br><span class="line">echo &quot;insert into t6 values(3,&#x27;abcdef&#x27;,&#x27;abcdef3&#x27;); &quot; |dbaccess db01</span><br><span class="line">echo &quot;insert into t6 values(4,&#x27;abcdef&#x27;,&#x27;abcdef4&#x27;); &quot; |dbaccess db01</span><br><span class="line">echo &quot;insert into t6 values(5,&#x27;abcdef&#x27;,&#x27;abcdef5&#x27;); &quot; |dbaccess db01</span><br><span class="line">echo &quot;insert into t6 values(6,&#x27;abcdef&#x27;,&#x27;abcdef6&#x27;); &quot; |dbaccess db01</span><br><span class="line">echo &quot;insert into t6 values(7,&#x27;abcdef&#x27;,&#x27;abcdef7&#x27;); &quot; |dbaccess db01</span><br><span class="line">echo &quot;insert into t6 values(8,&#x27;abcdef&#x27;,&#x27;abcdef8&#x27;); &quot; |dbaccess db01</span><br><span class="line">echo &quot;insert into t6 values(9,&#x27;abcdef&#x27;,&#x27;abcdef9&#x27;); &quot; |dbaccess db01</span><br><span class="line">echo &quot;insert into t6 values(10,&#x27;abcdef&#x27;,&#x27;abcdef10&#x27;); &quot; |dbaccess db01</span><br></pre></td></tr></table></figure>

<h4 id="老生产环境：关闭数据库"><a href="#老生产环境：关闭数据库" class="headerlink" title="老生产环境：关闭数据库"></a>老生产环境：关闭数据库</h4><pre><code>    这里我没有关闭数据库的方式表示，数据库坏了，并无法启动了。
</code></pre>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">onmode -ky</span><br><span class="line">onclean -ky</span><br></pre></td></tr></table></figure>

<h4 id="老生产环境：找到t6表的页"><a href="#老生产环境：找到t6表的页" class="headerlink" title="老生产环境：找到t6表的页"></a>老生产环境：找到t6表的页</h4><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br><span class="line">201</span><br><span class="line">202</span><br><span class="line">203</span><br><span class="line">204</span><br><span class="line">205</span><br><span class="line">206</span><br><span class="line">207</span><br><span class="line">208</span><br><span class="line">209</span><br><span class="line">210</span><br><span class="line">211</span><br><span class="line">212</span><br><span class="line">213</span><br><span class="line">214</span><br><span class="line">215</span><br><span class="line">216</span><br><span class="line">217</span><br><span class="line">218</span><br><span class="line">219</span><br><span class="line">220</span><br><span class="line">221</span><br><span class="line">222</span><br><span class="line">223</span><br><span class="line">224</span><br><span class="line">225</span><br><span class="line">226</span><br><span class="line">227</span><br><span class="line">228</span><br><span class="line">229</span><br><span class="line">230</span><br><span class="line">231</span><br><span class="line">232</span><br><span class="line">233</span><br><span class="line">234</span><br><span class="line">235</span><br><span class="line">236</span><br><span class="line">237</span><br><span class="line">238</span><br><span class="line">239</span><br><span class="line">240</span><br><span class="line">241</span><br><span class="line">242</span><br><span class="line">243</span><br><span class="line">244</span><br><span class="line">245</span><br><span class="line">246</span><br><span class="line">247</span><br><span class="line">248</span><br><span class="line">249</span><br><span class="line">250</span><br><span class="line">251</span><br><span class="line">252</span><br><span class="line">253</span><br><span class="line">254</span><br><span class="line">255</span><br><span class="line">256</span><br><span class="line">257</span><br><span class="line">258</span><br><span class="line">259</span><br><span class="line">260</span><br><span class="line">261</span><br><span class="line">262</span><br><span class="line">263</span><br><span class="line">264</span><br><span class="line">265</span><br><span class="line">266</span><br><span class="line">267</span><br><span class="line">268</span><br><span class="line">269</span><br><span class="line">270</span><br><span class="line">271</span><br><span class="line">272</span><br><span class="line">273</span><br><span class="line">274</span><br><span class="line">275</span><br><span class="line">276</span><br><span class="line">277</span><br><span class="line">278</span><br><span class="line">279</span><br><span class="line">280</span><br><span class="line">281</span><br><span class="line">282</span><br><span class="line">283</span><br><span class="line">284</span><br><span class="line">285</span><br><span class="line">286</span><br><span class="line">287</span><br><span class="line">288</span><br><span class="line">289</span><br><span class="line">290</span><br><span class="line">291</span><br><span class="line">292</span><br><span class="line">293</span><br><span class="line">294</span><br><span class="line">295</span><br><span class="line">296</span><br><span class="line">297</span><br><span class="line">298</span><br><span class="line">299</span><br><span class="line">300</span><br><span class="line">301</span><br><span class="line">302</span><br><span class="line">303</span><br><span class="line">304</span><br><span class="line">305</span><br><span class="line">306</span><br><span class="line">307</span><br><span class="line">308</span><br><span class="line">309</span><br><span class="line">310</span><br><span class="line">311</span><br><span class="line">312</span><br><span class="line">313</span><br><span class="line">314</span><br><span class="line">315</span><br><span class="line">316</span><br><span class="line">317</span><br><span class="line">318</span><br><span class="line">319</span><br><span class="line">320</span><br><span class="line">321</span><br><span class="line">322</span><br><span class="line">323</span><br><span class="line">324</span><br><span class="line">325</span><br><span class="line">326</span><br><span class="line">327</span><br><span class="line">328</span><br><span class="line">329</span><br><span class="line">330</span><br><span class="line">331</span><br><span class="line">332</span><br><span class="line">333</span><br><span class="line">334</span><br><span class="line">335</span><br><span class="line">336</span><br><span class="line">337</span><br><span class="line">338</span><br><span class="line">339</span><br><span class="line">340</span><br><span class="line">341</span><br><span class="line">342</span><br><span class="line">343</span><br><span class="line">344</span><br><span class="line">345</span><br><span class="line">346</span><br><span class="line">347</span><br><span class="line">348</span><br><span class="line">349</span><br><span class="line">350</span><br><span class="line">351</span><br><span class="line">352</span><br><span class="line">353</span><br><span class="line">354</span><br><span class="line">355</span><br><span class="line">356</span><br><span class="line">357</span><br><span class="line">358</span><br><span class="line">359</span><br><span class="line">360</span><br><span class="line">361</span><br><span class="line">362</span><br><span class="line">363</span><br><span class="line">364</span><br><span class="line">365</span><br><span class="line">366</span><br><span class="line">367</span><br><span class="line">368</span><br><span class="line">369</span><br><span class="line">370</span><br><span class="line">371</span><br><span class="line">372</span><br><span class="line">373</span><br><span class="line">374</span><br><span class="line">375</span><br><span class="line">376</span><br><span class="line">377</span><br><span class="line">378</span><br><span class="line">379</span><br><span class="line">380</span><br><span class="line">381</span><br><span class="line">382</span><br><span class="line">383</span><br><span class="line">384</span><br><span class="line">385</span><br><span class="line">386</span><br><span class="line">387</span><br><span class="line">388</span><br><span class="line">389</span><br><span class="line">390</span><br><span class="line">391</span><br><span class="line">392</span><br><span class="line">393</span><br><span class="line">394</span><br><span class="line">395</span><br><span class="line">396</span><br><span class="line">397</span><br><span class="line">398</span><br><span class="line">399</span><br><span class="line">400</span><br><span class="line">401</span><br><span class="line">402</span><br><span class="line">403</span><br><span class="line">404</span><br><span class="line">405</span><br><span class="line">406</span><br><span class="line">407</span><br><span class="line">408</span><br><span class="line">409</span><br><span class="line">410</span><br><span class="line">411</span><br><span class="line">412</span><br><span class="line">413</span><br><span class="line">414</span><br><span class="line">415</span><br><span class="line">416</span><br><span class="line">417</span><br><span class="line">418</span><br><span class="line">419</span><br><span class="line">420</span><br><span class="line">421</span><br><span class="line">422</span><br><span class="line">423</span><br><span class="line">424</span><br><span class="line">425</span><br><span class="line">426</span><br><span class="line">427</span><br><span class="line">428</span><br><span class="line">429</span><br><span class="line">430</span><br><span class="line">431</span><br><span class="line">432</span><br><span class="line">433</span><br><span class="line">434</span><br><span class="line">435</span><br><span class="line">436</span><br><span class="line">437</span><br><span class="line">438</span><br><span class="line">439</span><br><span class="line">440</span><br><span class="line">441</span><br><span class="line">442</span><br><span class="line">443</span><br><span class="line">444</span><br><span class="line">445</span><br><span class="line">446</span><br><span class="line">447</span><br><span class="line">448</span><br><span class="line">449</span><br><span class="line">450</span><br><span class="line">451</span><br><span class="line">452</span><br><span class="line">453</span><br><span class="line">454</span><br><span class="line">455</span><br><span class="line">456</span><br><span class="line">457</span><br><span class="line">458</span><br><span class="line">459</span><br><span class="line">460</span><br><span class="line">461</span><br><span class="line">462</span><br><span class="line">463</span><br><span class="line">464</span><br><span class="line">465</span><br><span class="line">466</span><br><span class="line">467</span><br><span class="line">468</span><br><span class="line">469</span><br><span class="line">470</span><br><span class="line">471</span><br><span class="line">472</span><br><span class="line">473</span><br><span class="line">474</span><br><span class="line">475</span><br><span class="line">476</span><br><span class="line">477</span><br><span class="line">478</span><br><span class="line">479</span><br><span class="line">480</span><br><span class="line">481</span><br><span class="line">482</span><br><span class="line">483</span><br><span class="line">484</span><br><span class="line">485</span><br><span class="line">486</span><br><span class="line">487</span><br><span class="line">488</span><br><span class="line">489</span><br><span class="line">490</span><br><span class="line">491</span><br><span class="line">492</span><br></pre></td><td class="code"><pre><span class="line">[gbasedbt@wei07 GBase8sL3]$</span><br><span class="line">[gbasedbt@wei07 GBase8sL3]$  ./dumpTBLSpaceAndPE.sh</span><br><span class="line"></span><br><span class="line">DBspace number      DBspace name        Flags               Number of chunks    First chunk         Pagesize</span><br><span class="line">1                   rootdbs             0x60001             1                   1                   2</span><br><span class="line">2                   plogdbs             0x60001             1                   2                   2</span><br><span class="line">3                   llogdbs             0x60001             1                   3                   2</span><br><span class="line">4                   tmpdbs01            0x42001             1                   4                   2</span><br><span class="line">5                   tmpdbs02            0x42001             1                   5                   2</span><br><span class="line">6                   tmpdbs03            0x42001             1                   6                   2</span><br><span class="line">7                   tmpdbs04            0x42001             1                   7                   2</span><br><span class="line">8                   datadbs01           0x60001             1                   8                   16</span><br><span class="line"></span><br><span class="line">Chunk number        Flags               Chunk path                                        Chunk offset        Chunk size          Number of free page DBspace number</span><br><span class="line">1                   0x10040             /opt/data/rootchk                                 0                   512000              351312              1</span><br><span class="line">2                   0x30040             /opt/data/plogdbs                                 0                   5000                4947                2</span><br><span class="line">3                   0x30040             /opt/data/llogdbs                                 0                   5000                4947                3</span><br><span class="line">4                   0x30040             /opt/data/tmpdbs01                                0                   5000                4947                4</span><br><span class="line">5                   0x30040             /opt/data/tmpdbs02                                0                   5000                4947                5</span><br><span class="line">6                   0x30040             /opt/data/tmpdbs03                                0                   5000                4947                6</span><br><span class="line">7                   0x30040             /opt/data/tmpdbs04                                0                   5000                4947                7</span><br><span class="line">8                   0x30040             /opt/data/datachk01                               0                   25600               23905               8</span><br><span class="line">请输入dbs名称：</span><br><span class="line">datadbs01</span><br><span class="line">16384+0 records in</span><br><span class="line">16384+0 records out</span><br><span class="line">16384 bytes (16 kB) copied, 0.0523441 s, 313 kB/s</span><br><span class="line">50+0 records in</span><br><span class="line">50+0 records out</span><br><span class="line">50 bytes (50 B) copied, 0.000194981 s, 256 kB/s</span><br><span class="line">10+0 records in</span><br><span class="line">10+0 records out</span><br><span class="line">10 bytes (10 B) copied, 0.000176686 s, 56.6 kB/s</span><br><span class="line">10+0 records in</span><br><span class="line">10+0 records out</span><br><span class="line">10 bytes (10 B) copied, 0.000125911 s, 79.4 kB/s</span><br><span class="line">10+0 records in</span><br><span class="line">10+0 records out</span><br><span class="line">10 bytes (10 B) copied, 0.000118567 s, 84.3 kB/s</span><br><span class="line">10+0 records in</span><br><span class="line">10+0 records out</span><br><span class="line">10 bytes (10 B) copied, 0.000122428 s, 81.7 kB/s</span><br><span class="line">16 2</span><br><span class="line">      0x0008   0x00000018   0x00000032            8            3           50         16 /opt/data/datachk01</span><br><span class="line">      0x0008   0x00000848   0x00000064            8          265           50         16 /opt/data/datachk01</span><br><span class="line">      0x0008   0x000015d8   0x000000c8            8          699          100         16 /opt/data/datachk01</span><br><span class="line">      0x0008   0x000025b8   0x00000190            8         1207          200         16 /opt/data/datachk01</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">DBspace Usage Report: datadbs01           Owner: wangwei  Created: 05/09/2022</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"> Chunk Pathname                             Pagesize(k)  Size(p)  Used(p)  Free(p)</span><br><span class="line">     8 /opt/data/datachk01                           16   xxxxx     xxxxx   xxxxx</span><br><span class="line"></span><br><span class="line"> Description                                                   Offset(p)  Size(p)</span><br><span class="line"> ------------------------------------------------------------- -------- --------</span><br><span class="line"> RESERVED PAGES                                                       0        2</span><br><span class="line"> CHUNK FREELIST PAGE                                                  2        1</span><br><span class="line"> datadbs01:TBLSpace                                                   3       50</span><br><span class="line"> datadbs01:TBLSpace                                                 265       50</span><br><span class="line"> datadbs01:TBLSpace                                                 699      100</span><br><span class="line"> datadbs01:TBLSpace                                                1207      200</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000003 skip=3 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000004 skip=4 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000005 skip=5 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000006 skip=6 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000007 skip=7 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000008 skip=8 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000009 skip=9 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000000a skip=10 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000000b skip=11 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000000c skip=12 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000000d skip=13 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000000e skip=14 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000000f skip=15 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000010 skip=16 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000011 skip=17 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000012 skip=18 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000013 skip=19 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000014 skip=20 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000015 skip=21 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000016 skip=22 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000017 skip=23 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000018 skip=24 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000019 skip=25 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000001a skip=26 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000001b skip=27 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000001c skip=28 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000001d skip=29 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000001e skip=30 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000001f skip=31 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000020 skip=32 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000021 skip=33 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000022 skip=34 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000023 skip=35 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000024 skip=36 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000025 skip=37 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000026 skip=38 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000027 skip=39 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000028 skip=40 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000029 skip=41 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000002a skip=42 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000002b skip=43 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000002c skip=44 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000002d skip=45 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000002e skip=46 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000002f skip=47 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000030 skip=48 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000031 skip=49 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000032 skip=50 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000033 skip=51 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000034 skip=52 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000109 skip=265 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000010a skip=266 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000010b skip=267 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000010c skip=268 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000010d skip=269 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000010e skip=270 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000010f skip=271 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000110 skip=272 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000111 skip=273 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000112 skip=274 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000113 skip=275 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000114 skip=276 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000115 skip=277 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000116 skip=278 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000117 skip=279 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000118 skip=280 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000119 skip=281 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000011a skip=282 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000011b skip=283 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000011c skip=284 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000011d skip=285 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000011e skip=286 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000011f skip=287 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000120 skip=288 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000121 skip=289 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000122 skip=290 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000123 skip=291 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000124 skip=292 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000125 skip=293 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000126 skip=294 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000127 skip=295 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000128 skip=296 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000129 skip=297 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000012a skip=298 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000012b skip=299 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000012c skip=300 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000012d skip=301 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000012e skip=302 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000012f skip=303 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000130 skip=304 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000131 skip=305 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000132 skip=306 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000133 skip=307 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000134 skip=308 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000135 skip=309 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000136 skip=310 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000137 skip=311 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000138 skip=312 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000139 skip=313 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000013a skip=314 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002bb skip=699 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002bc skip=700 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002bd skip=701 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002be skip=702 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002bf skip=703 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002c0 skip=704 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002c1 skip=705 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002c2 skip=706 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002c3 skip=707 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002c4 skip=708 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002c5 skip=709 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002c6 skip=710 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002c7 skip=711 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002c8 skip=712 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002c9 skip=713 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002ca skip=714 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002cb skip=715 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002cc skip=716 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002cd skip=717 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002ce skip=718 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002cf skip=719 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002d0 skip=720 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002d1 skip=721 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002d2 skip=722 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002d3 skip=723 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002d4 skip=724 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002d5 skip=725 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002d6 skip=726 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002d7 skip=727 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002d8 skip=728 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002d9 skip=729 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002da skip=730 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002db skip=731 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002dc skip=732 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002dd skip=733 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002de skip=734 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002df skip=735 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002e0 skip=736 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002e1 skip=737 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002e2 skip=738 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002e3 skip=739 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002e4 skip=740 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002e5 skip=741 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002e6 skip=742 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002e7 skip=743 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002e8 skip=744 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002e9 skip=745 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002ea skip=746 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002eb skip=747 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002ec skip=748 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002ed skip=749 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002ee skip=750 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002ef skip=751 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002f0 skip=752 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002f1 skip=753 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002f2 skip=754 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002f3 skip=755 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002f4 skip=756 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002f5 skip=757 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002f6 skip=758 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002f7 skip=759 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002f8 skip=760 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002f9 skip=761 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002fa skip=762 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002fb skip=763 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002fc skip=764 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002fd skip=765 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002fe skip=766 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000002ff skip=767 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000300 skip=768 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000301 skip=769 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000302 skip=770 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000303 skip=771 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000304 skip=772 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000305 skip=773 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000306 skip=774 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000307 skip=775 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000308 skip=776 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000309 skip=777 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000030a skip=778 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000030b skip=779 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000030c skip=780 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000030d skip=781 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000030e skip=782 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000030f skip=783 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000310 skip=784 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000311 skip=785 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000312 skip=786 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000313 skip=787 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000314 skip=788 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000315 skip=789 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000316 skip=790 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000317 skip=791 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000318 skip=792 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000319 skip=793 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000031a skip=794 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000031b skip=795 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000031c skip=796 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000031d skip=797 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000031e skip=798 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004b7 skip=1207 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004b8 skip=1208 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004b9 skip=1209 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004ba skip=1210 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004bb skip=1211 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004bc skip=1212 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004bd skip=1213 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004be skip=1214 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004bf skip=1215 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004c0 skip=1216 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004c1 skip=1217 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004c2 skip=1218 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004c3 skip=1219 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004c4 skip=1220 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004c5 skip=1221 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004c6 skip=1222 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004c7 skip=1223 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004c8 skip=1224 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004c9 skip=1225 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004ca skip=1226 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004cb skip=1227 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004cc skip=1228 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004cd skip=1229 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004ce skip=1230 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004cf skip=1231 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004d0 skip=1232 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004d1 skip=1233 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004d2 skip=1234 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004d3 skip=1235 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004d4 skip=1236 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004d5 skip=1237 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004d6 skip=1238 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004d7 skip=1239 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004d8 skip=1240 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004d9 skip=1241 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004da skip=1242 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004db skip=1243 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004dc skip=1244 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004dd skip=1245 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004de skip=1246 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004df skip=1247 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004e0 skip=1248 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004e1 skip=1249 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004e2 skip=1250 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004e3 skip=1251 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004e4 skip=1252 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004e5 skip=1253 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004e6 skip=1254 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004e7 skip=1255 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004e8 skip=1256 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004e9 skip=1257 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004ea skip=1258 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004eb skip=1259 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004ec skip=1260 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004ed skip=1261 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004ee skip=1262 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004ef skip=1263 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004f0 skip=1264 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004f1 skip=1265 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004f2 skip=1266 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004f3 skip=1267 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004f4 skip=1268 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004f5 skip=1269 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004f6 skip=1270 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004f7 skip=1271 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004f8 skip=1272 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004f9 skip=1273 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004fa skip=1274 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004fb skip=1275 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004fc skip=1276 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004fd skip=1277 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004fe skip=1278 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x000004ff skip=1279 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000500 skip=1280 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000501 skip=1281 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000502 skip=1282 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000503 skip=1283 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000504 skip=1284 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000505 skip=1285 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000506 skip=1286 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000507 skip=1287 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000508 skip=1288 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000509 skip=1289 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000050a skip=1290 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000050b skip=1291 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000050c skip=1292 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000050d skip=1293 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000050e skip=1294 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000050f skip=1295 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000510 skip=1296 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000511 skip=1297 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000512 skip=1298 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000513 skip=1299 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000514 skip=1300 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000515 skip=1301 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000516 skip=1302 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000517 skip=1303 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000518 skip=1304 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000519 skip=1305 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000051a skip=1306 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000051b skip=1307 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000051c skip=1308 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000051d skip=1309 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000051e skip=1310 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000051f skip=1311 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000520 skip=1312 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000521 skip=1313 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000522 skip=1314 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000523 skip=1315 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000524 skip=1316 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000525 skip=1317 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000526 skip=1318 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000527 skip=1319 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000528 skip=1320 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000529 skip=1321 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000052a skip=1322 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000052b skip=1323 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000052c skip=1324 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000052d skip=1325 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000052e skip=1326 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000052f skip=1327 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000530 skip=1328 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000531 skip=1329 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000532 skip=1330 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000533 skip=1331 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000534 skip=1332 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000535 skip=1333 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000536 skip=1334 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000537 skip=1335 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000538 skip=1336 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000539 skip=1337 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000053a skip=1338 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000053b skip=1339 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000053c skip=1340 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000053d skip=1341 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000053e skip=1342 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000053f skip=1343 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000540 skip=1344 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000541 skip=1345 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000542 skip=1346 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000543 skip=1347 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000544 skip=1348 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000545 skip=1349 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000546 skip=1350 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000547 skip=1351 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000548 skip=1352 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000549 skip=1353 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000054a skip=1354 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000054b skip=1355 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000054c skip=1356 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000054d skip=1357 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000054e skip=1358 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000054f skip=1359 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000550 skip=1360 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000551 skip=1361 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000552 skip=1362 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000553 skip=1363 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000554 skip=1364 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000555 skip=1365 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000556 skip=1366 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000557 skip=1367 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000558 skip=1368 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000559 skip=1369 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000055a skip=1370 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000055b skip=1371 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000055c skip=1372 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000055d skip=1373 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000055e skip=1374 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000055f skip=1375 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000560 skip=1376 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000561 skip=1377 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000562 skip=1378 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000563 skip=1379 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000564 skip=1380 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000565 skip=1381 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000566 skip=1382 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000567 skip=1383 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000568 skip=1384 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000569 skip=1385 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000056a skip=1386 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000056b skip=1387 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000056c skip=1388 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000056d skip=1389 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000056e skip=1390 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000056f skip=1391 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000570 skip=1392 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000571 skip=1393 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000572 skip=1394 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000573 skip=1395 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000574 skip=1396 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000575 skip=1397 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000576 skip=1398 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000577 skip=1399 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000578 skip=1400 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x00000579 skip=1401 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000057a skip=1402 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000057b skip=1403 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000057c skip=1404 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000057d skip=1405 bs=16384 count=1</span><br><span class="line">dd if=/opt/data/datachk01 of=0x008/0x0000057e skip=1406 bs=16384 count=1</span><br><span class="line">请输入你要抢救数据的表所在的数据库名称：</span><br><span class="line">db01</span><br><span class="line">请输入你要抢救数据的表名称：</span><br><span class="line">t6</span><br><span class="line">0000000: 1009 0000 0800 5aff 0538 0208 e000 083f 0000 0000 0000 0000 4b00 8000 0209 0000 2400 0000 0100 0000 0100 0040 47f1 8264 0100 0000 2000 0000 4000 0000 0400 0000 0200 0000 0100 0000 ffff ffff 4b00 8000 0100 0000 0000 0000 0a00 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0a00 0000 0100 0000 0000 0000 0100 0000 0100 0000 0000 0000 0100 0000 0100 0000 bc87 3f02 0000 0000 0000 0000 0000 0000 6462 3031 0067 6261 7365 6462 7400 7436 007a 685f 434e 2e35 3733 3732 0000 0000 0400 0000 0000 1400 0000 0005 0000 0000 0008 0000 12b8 0000 0004 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000  ......Z..8.....?........K.......$..........@G..d.... ...@...................K.....................................................................?.............db01.gbasedbt.t6.zh_CN.57372....................................................................</span><br><span class="line">这个文件就是你要找的partation页！！！  partationDIR/0x00000122</span><br><span class="line">20+0 records in</span><br><span class="line">20+0 records out</span><br><span class="line">20 bytes (20 B) copied, 0.000139988 s, 143 kB/s</span><br><span class="line">10+0 records in</span><br><span class="line">10+0 records out</span><br><span class="line">10 bytes (10 B) copied, 0.000136798 s, 73.1 kB/s</span><br><span class="line">16 2</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">DBspace Usage Report: db01           Owner: wangwei  Created: 05/09/2022</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"> Chunk Pathname                             Pagesize(k)  Size(p)  Used(p)  Free(p)</span><br><span class="line">     8 /opt/data/datachk01                           16   xxxxx     xxxxx   xxxxx</span><br><span class="line"></span><br><span class="line"> Description                                                   Offset(p)  Size(p)</span><br><span class="line"> ------------------------------------------------------------- -------- --------</span><br><span class="line"> RESERVED PAGES                                                       0        2</span><br><span class="line"> CHUNK FREELIST PAGE                                                  2        1</span><br><span class="line"> db01:t6                                                            599        4</span><br><span class="line"></span><br><span class="line">[gbasedbt@wei07 GBase8sL3]$</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>注明，可以看到t6表有这些页：</p>
<ol>
<li>#define PG_PARTN     0x0002       &#x2F;* Partition page       *&#x2F;                      partationDIR&#x2F;0x00000122</li>
<li>#define FR_BMORINDEX    0x8     &#x2F;* Index or bitmap page *&#x2F;              db01:t6    599        4</li>
<li>#define PG_DATA      0x0001       &#x2F;* Data page            *&#x2F;                         db01:t6    599        4</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br></pre></td><td class="code"><pre><span class="line">[gbasedbt@wei07 GBase8sL3]$ xxd partationDIR/0x00000122  |head -30</span><br><span class="line">0000000: 1009 0000 0800 5aff 0538 0208 e000 083f  ......Z..8.....?</span><br><span class="line">0000010: 0000 0000 0000 0000 4b00 8000 0209 0000  ........K.......</span><br><span class="line">0000020: 2400 0000 0100 0000 0100 0040 47f1 8264  $..........@G..d</span><br><span class="line">0000030: 0100 0000 2000 0000 4000 0000 0400 0000  .... ...@.......</span><br><span class="line">0000040: 0200 0000 0100 0000 ffff ffff 4b00 8000  ............K...</span><br><span class="line">0000050: 0100 0000 0000 0000 0a00 0000 0000 0000  ................</span><br><span class="line">0000060: 0000 0000 0000 0000 0000 0000 0000 0000  ................</span><br><span class="line">0000070: 0a00 0000 0100 0000 0000 0000 0100 0000  ................</span><br><span class="line">0000080: 0100 0000 0000 0000 0100 0000 0100 0000  ................</span><br><span class="line">0000090: bc87 3f02 0000 0000 0000 0000 0000 0000  ..?.............</span><br><span class="line">00000a0: 6462 3031 0067 6261 7365 6462 7400 7436  db01.gbasedbt.t6</span><br><span class="line">00000b0: 007a 685f 434e 2e35 3733 3732 0000 0000  .zh_CN.57372....</span><br><span class="line">00000c0: 0400 0000 0000 1400 0000 0005 0000 0000  ................</span><br><span class="line">00000d0: 0008 0000 12b8 0000 0004 0000 0000 0000  ................</span><br><span class="line">00000e0: 0000 0000 0000 0000 0000 0000 0000 0000  ................</span><br><span class="line">00000f0: 0000 0000 0000 0000 0000 0000 0000 0000  ................</span><br><span class="line">0000100: 0000 0000 0000 0000 0000 0000 0000 0000  ................</span><br><span class="line">0000110: 0000 0000 0000 0000 0000 0000 0000 0000  ................</span><br><span class="line">0000120: 0000 0000 0000 0000 0000 0000 0000 0000  ................</span><br><span class="line">0000130: 0000 0000 0000 0000 0000 0000 0000 0000  ................</span><br><span class="line">0000140: 0000 0000 0000 0000 0000 0000 0000 0000  ................</span><br><span class="line">0000150: 0000 0000 0000 0000 0000 0000 0000 0000  ................</span><br><span class="line">0000160: 0000 0000 0000 0000 0000 0000 0000 0000  ................</span><br><span class="line">0000170: 0000 0000 0000 0000 0000 0000 0000 0000  ................</span><br><span class="line">0000180: 0000 0000 0000 0000 0000 0000 0000 0000  ................</span><br><span class="line">0000190: 0000 0000 0000 0000 0000 0000 0000 0000  ................</span><br><span class="line">00001a0: 0000 0000 0000 0000 0000 0000 0000 0000  ................</span><br><span class="line">00001b0: 0000 0000 0000 0000 0000 0000 0000 0000  ................</span><br><span class="line">00001c0: 0000 0000 0000 0000 0000 0000 0000 0000  ................</span><br><span class="line">00001d0: 0000 0000 0000 0000 0000 0000 0000 0000  ................</span><br><span class="line">[gbasedbt@wei07 GBase8sL3]$</span><br><span class="line">[gbasedbt@wei07 GBase8sL3]$ xxd partationDIR/0x00000122  |tail -10</span><br><span class="line">0003f60: 0000 0000 0000 0000 0000 0000 0000 0000  ................</span><br><span class="line">0003f70: 0000 0000 0000 0000 0000 0000 0000 0000  ................</span><br><span class="line">0003f80: 0000 0000 0000 0000 0000 0000 0000 0000  ................</span><br><span class="line">0003f90: 0000 0000 0000 0000 0000 0000 0000 0000  ................</span><br><span class="line">0003fa0: 0000 0000 0000 0000 0000 0000 0000 0000  ................</span><br><span class="line">0003fb0: 0000 0000 0000 0000 0000 0000 0000 0000  ................</span><br><span class="line">0003fc0: 0000 0000 0000 0000 0000 0000 0000 0000  ................</span><br><span class="line">0003fd0: 0000 0000 0000 0000 0000 0000 0000 0000  ................</span><br><span class="line">0003fe0: 0000 0000 0000 0000 cc00 1400 cc00 0000  ................</span><br><span class="line">0003ff0: c000 0c00 a000 2000 1800 8800 40f6 0200  ...... .....@...</span><br><span class="line">[gbasedbt@wei07 GBase8sL3]$</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h4 id="老生产环境：下载t6表的页"><a href="#老生产环境：下载t6表的页" class="headerlink" title="老生产环境：下载t6表的页"></a>老生产环境：下载t6表的页</h4><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br></pre></td><td class="code"><pre><span class="line">filePe=&quot;db01:t6.pe&quot;</span><br><span class="line">dbname=&quot;db01&quot;</span><br><span class="line">tabename=&quot;t6&quot;</span><br><span class="line">rootPagesize=2</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">Chunk=0</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">Pathname=0</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">Pagesize=0</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">Offset=0</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">Size=0</span></span><br><span class="line">cat $filePe |grep -E &quot;xxxxx|$&#123;dbname&#125;:$&#123;tabname&#125;&quot; |awk &#x27;&#123;</span><br><span class="line"><span class="meta prompt_">	if($</span><span class="language-bash">5==<span class="string">&quot;xxxxx&quot;</span>)&#123;</span></span><br><span class="line">		Chunk=$1;</span><br><span class="line">		Pathname=$2;</span><br><span class="line">		Pagesize=$3;</span><br><span class="line">	&#125;else&#123;</span><br><span class="line">	    dbtab=$1;</span><br><span class="line">		Offset=$2;</span><br><span class="line">		Size=$3;</span><br><span class="line">		print dbtab,Chunk,Pathname,Pagesize,Offset,Size ;</span><br><span class="line">	&#125;</span><br><span class="line">&#125;&#x27; &gt; $&#123;dbname&#125;:$&#123;tabename&#125;.pe.line</span><br><span class="line"></span><br><span class="line">rm -fr datapageDIR</span><br><span class="line">mkdir datapageDIR</span><br><span class="line">cat $&#123;dbname&#125;:$&#123;tabename&#125;.pe.line |while read dbtab Chunk Pathname Pagesize Offset Size</span><br><span class="line">do</span><br><span class="line">	i=$Offset</span><br><span class="line">	let e=$Offset+$Size</span><br><span class="line">	while [ $i -lt $e ];do</span><br><span class="line">		outfile=datapageDIR/$&#123;dbtab&#125;_$&#123;i&#125;; &gt;$outfile;</span><br><span class="line">		let skip=$&#123;i&#125;*$&#123;Pagesize&#125;*1</span><br><span class="line">		let seek=0</span><br><span class="line">		let bs=1024</span><br><span class="line">		let count=$&#123;Pagesize&#125;*1</span><br><span class="line">		dd1 $Pathname $outfile $skip $seek $bs $count 1 1</span><br><span class="line">		let i=$i+1</span><br><span class="line">	done</span><br><span class="line">done</span><br></pre></td></tr></table></figure>



<h4 id="手术台上的操作：初始化一个空实例"><a href="#手术台上的操作：初始化一个空实例" class="headerlink" title="手术台上的操作：初始化一个空实例"></a>手术台上的操作：初始化一个空实例</h4><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">w01_init_env_02.sh</span></span><br><span class="line">onmode -ky</span><br><span class="line">onclean -ky</span><br><span class="line">rm -fr /opt/data/*</span><br><span class="line">touch /opt/data/rootchk</span><br><span class="line">touch /opt/data/plogdbs</span><br><span class="line">touch /opt/data/llogdbs</span><br><span class="line">touch /opt/data/tmpdbs01</span><br><span class="line">touch /opt/data/tmpdbs02</span><br><span class="line">touch /opt/data/tmpdbs03</span><br><span class="line">touch /opt/data/tmpdbs04</span><br><span class="line">touch /opt/data/datachk01</span><br><span class="line">chmod 660 /opt/data/*</span><br><span class="line"></span><br><span class="line">sed -i &#x27;s/^FULL_DISK_INIT.*$/FULL_DISK_INIT 1/&#x27; $GBASEDBTDIR/etc/$ONCONFIG</span><br><span class="line">sed -i &#x27;s/^PHYSFILE.*$/#PHYSFILE/&#x27; $GBASEDBTDIR/etc/$ONCONFIG</span><br><span class="line">sed -i &#x27;s/^LOGFILES.*$/LOGFILES/&#x27; $GBASEDBTDIR/etc/$ONCONFIG</span><br><span class="line">sed -i &#x27;s/^LOGSIZE.*$/LOGSIZE/&#x27; $GBASEDBTDIR/etc/$ONCONFIG</span><br><span class="line">oninit -ivy</span><br><span class="line"></span><br><span class="line">onspaces -c -d plogdbs -p /opt/data/plogdbs -o 0 -s 10000 </span><br><span class="line">onspaces -c -d llogdbs -p /opt/data/llogdbs -o 0 -s 10000 </span><br><span class="line">onspaces -c -d tmpdbs01 -p /opt/data/tmpdbs01 -o 0 -s 10000 -t</span><br><span class="line">onspaces -c -d tmpdbs02 -p /opt/data/tmpdbs02 -o 0 -s 10000 -t</span><br><span class="line">onspaces -c -d tmpdbs03 -p /opt/data/tmpdbs03 -o 0 -s 10000 -t</span><br><span class="line">onspaces -c -d tmpdbs04 -p /opt/data/tmpdbs04 -o 0 -s 10000 -t</span><br><span class="line">onspaces -c -d datadbs01 -p /opt/data/datachk01 -o 0 -k 16 -s `echo &quot;25600*16&quot;|bc`</span><br><span class="line"></span><br><span class="line">sleep 1;</span><br><span class="line">onmode -c</span><br><span class="line">ontape -s -L 0 -t /dev/null</span><br><span class="line"></span><br><span class="line">dbaccess - - &lt;&lt;!</span><br><span class="line">    create database db01 in datadbs01;</span><br><span class="line">!</span><br></pre></td></tr></table></figure>



<h4 id="手术台上的操作：创建一个t6表"><a href="#手术台上的操作：创建一个t6表" class="headerlink" title="手术台上的操作：创建一个t6表"></a>手术台上的操作：创建一个t6表</h4><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">创建一个空的t6表</span></span><br><span class="line">dbaccess db01 &lt;&lt;!</span><br><span class="line">	create table t6(id int,name varchar(20), addr char(10)) </span><br><span class="line">    extent size 64 next size 128;</span><br><span class="line">!</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">现在t6表是没有数据的</span></span><br><span class="line">dbaccess db01 &lt;&lt;!</span><br><span class="line">	select * from t6;</span><br><span class="line">!</span><br></pre></td></tr></table></figure>



<h4 id="手术台上的操作：观察新实例的数据页情况"><a href="#手术台上的操作：观察新实例的数据页情况" class="headerlink" title="手术台上的操作：观察新实例的数据页情况"></a>手术台上的操作：观察新实例的数据页情况</h4><pre><code>    关闭数据库，下载新t6表的partation页，查看新t6表的数据页分配情况。如果没有分配可以随意插入数据再truncat掉，尽量保证页分配数和老生产环境一致。
</code></pre>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br></pre></td><td class="code"><pre><span class="line">onmode -ky</span><br><span class="line">onclean -ky</span><br><span class="line">mkdir /home/gbasedbt/GBase8sL3/new</span><br><span class="line">cd /home/gbasedbt/GBase8sL3/new</span><br><span class="line">cp -a ../dumpTBLSpaceAndPE.sh ./</span><br><span class="line">cp -a ../dumpPEpage.sh ./</span><br><span class="line">cp -a ../dd1 ./</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">[gbasedbt@wei07 new]$ ./dumpPEpage.sh</span></span><br><span class="line">if=/opt/data/datachk01 of=datapageDIR/db01:t6_583 skip=9328 seed=0 bs=1024 count=16 itw=1 otw=1</span><br><span class="line">if=/opt/data/datachk01 of=datapageDIR/db01:t6_584 skip=9344 seed=0 bs=1024 count=16 itw=1 otw=1</span><br><span class="line">if=/opt/data/datachk01 of=datapageDIR/db01:t6_585 skip=9360 seed=0 bs=1024 count=16 itw=1 otw=1</span><br><span class="line">if=/opt/data/datachk01 of=datapageDIR/db01:t6_586 skip=9376 seed=0 bs=1024 count=16 itw=1 otw=1</span><br><span class="line">[gbasedbt@wei07 new]$</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">[gbasedbt@wei07 new]$ ./dumpTBLSpaceAndPE</span></span><br><span class="line">请输入你要抢救数据的表所在的数据库名称：</span><br><span class="line">db01</span><br><span class="line">请输入你要抢救数据的表名称：</span><br><span class="line">t6</span><br><span class="line">0000000: f008 0000 0800 5fd4 0538 0208 e000 083f 0000 0000 0000 0000 4700 8000 0209 0000 2400 0000 0100 0000 0100 0040 cc07 8364 0100 0000 2000 0000 4000 0000 0400 0000 0100 0000 0000 0000 ffff ffff 4700 8000 0100 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0100 0000 0000 0000 0100 0000 0100 0000 0000 0000 0100 0000 0100 0000 78c1 c302 0000 0000 0000 0000 0000 0000 6462 3031 0067 6261 7365 6462 7400 7436 007a 685f 434e 2e35 3733 3732 0000 0000 0400 0000 0000 1400 0000 0005 0000 0000 0008 0000 1238 0000 0004 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000  ......_..8.....?........G.......$..........@...d.... ...@...................G...................................................................x...............db01.gbasedbt.t6.zh_CN.57372.........................8..........................................</span><br><span class="line">这个文件就是你要找的partation页！！！  partationDIR/0x0000011e</span><br><span class="line">20+0 records in</span><br><span class="line">20+0 records out</span><br><span class="line">20 bytes (20 B) copied, 0.000140423 s, 142 kB/s</span><br><span class="line">10+0 records in</span><br><span class="line">10+0 records out</span><br><span class="line">10 bytes (10 B) copied, 0.000122007 s, 82.0 kB/s</span><br><span class="line">16 2</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">DBspace Usage Report: db01           Owner: wangwei  Created: 05/09/2022</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"> Chunk Pathname                             Pagesize(k)  Size(p)  Used(p)  Free(p)</span><br><span class="line">     8 /opt/data/datachk01                           16   xxxxx     xxxxx   xxxxx</span><br><span class="line"></span><br><span class="line"> Description                                                   Offset(p)  Size(p)</span><br><span class="line"> ------------------------------------------------------------- -------- --------</span><br><span class="line"> RESERVED PAGES                                                       0        2</span><br><span class="line"> CHUNK FREELIST PAGE                                                  2        1</span><br><span class="line"> db01:t6                                                            583        4</span><br><span class="line"></span><br><span class="line">[gbasedbt@wei07 new]$</span><br><span class="line"></span><br></pre></td></tr></table></figure>



<h4 id="手术台上的操作：修改partation页"><a href="#手术台上的操作：修改partation页" class="headerlink" title="手术台上的操作：修改partation页"></a>手术台上的操作：修改partation页</h4><h5 id="partation页：对比"><a href="#partation页：对比" class="headerlink" title="partation页：对比"></a>partation页：对比</h5><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="built_in">cd</span> new</span></span><br><span class="line">mkdir diffDir</span><br><span class="line">xxd ../partationDIR/0x00000122 &gt; diffDir/old.partn</span><br><span class="line">xxd ./partationDIR/0x0000011e  &gt; diffDir/new.partn</span><br><span class="line">diff diffDir/old.partn diffDir/new.partn</span><br></pre></td></tr></table></figure>

<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br></pre></td><td class="code"><pre><span class="line">[gbasedbt@wei07 new]$ diff diffDir/old.partn diffDir/new.partn</span><br><span class="line">1,3c1,3</span><br><span class="line">&lt; 0000000: 1009 0000 0800 5aff 0538 0208 e000 083f  ......Z..8.....?</span><br><span class="line">&lt; 0000010: 0000 0000 0000 0000 4b00 8000 0209 0000  ........K.......</span><br><span class="line">&lt; 0000020: 2400 0000 0100 0000 0100 0040 47f1 8264  $..........@G..d</span><br><span class="line">---</span><br><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash">0000000: f008 0000 0800 5fd4 0538 0208 e000 083f  ......_..8.....?</span></span><br><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash">0000010: 0000 0000 0000 0000 4700 8000 0209 0000  ........G.......</span></span><br><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash">0000020: 2400 0000 0100 0000 0100 0040 cc07 8364  $..........@...d</span></span><br><span class="line">5,6c5,6</span><br><span class="line">&lt; 0000040: 0200 0000 0100 0000 ffff ffff 4b00 8000  ............K...</span><br><span class="line">&lt; 0000050: 0100 0000 0000 0000 0a00 0000 0000 0000  ................</span><br><span class="line">---</span><br><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash">0000040: 0100 0000 0000 0000 ffff ffff 4700 8000  ............G...</span></span><br><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash">0000050: 0100 0000 0000 0000 0000 0000 0000 0000  ................</span></span><br><span class="line">8c8</span><br><span class="line">&lt; 0000070: 0a00 0000 0100 0000 0000 0000 0100 0000  ................</span><br><span class="line">---</span><br><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash">0000070: 0000 0000 0100 0000 0000 0000 0100 0000  ................</span></span><br><span class="line">10c10</span><br><span class="line">&lt; 0000090: bc87 3f02 0000 0000 0000 0000 0000 0000  ..?.............</span><br><span class="line">---</span><br><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash">0000090: 78c1 c302 0000 0000 0000 0000 0000 0000  x...............</span></span><br><span class="line">14c14</span><br><span class="line">&lt; 00000d0: 0008 0000 12b8 0000 0004 0000 0000 0000  ................</span><br><span class="line">---</span><br><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash">00000d0: 0008 0000 1238 0000 0004 0000 0000 0000  .....8..........</span></span><br><span class="line">1024c1024</span><br><span class="line">&lt; 0003ff0: c000 0c00 a000 2000 1800 8800 40f6 0200  ...... .....@...</span><br><span class="line">---</span><br><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash">0003ff0: c000 0c00 a000 2000 1800 8800 a5dc 0200  ...... .........</span></span><br><span class="line">[gbasedbt@wei07 new]$</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h5 id="partation页：覆盖槽位1"><a href="#partation页：覆盖槽位1" class="headerlink" title="partation页：覆盖槽位1"></a>partation页：覆盖槽位1</h5><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="built_in">cd</span> new</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">0x08f0 = 2288</span></span><br><span class="line">if=../partationDIR/0x00000122</span><br><span class="line">of=/opt/data/datachk01</span><br><span class="line">let skip=24</span><br><span class="line">let seek=2288*2*1024+24</span><br><span class="line">let bs=1</span><br><span class="line">let count=136</span><br><span class="line">dd1 $if $of $skip $seek $bs $count 1 1</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"> 242: Could not open database table (root.t7).</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"> 135: ISAM error: TBLspace does not exist</span></span><br></pre></td></tr></table></figure>

<h5 id="partation页：细修槽位1-partnum和lockid"><a href="#partation页：细修槽位1-partnum和lockid" class="headerlink" title="partation页：细修槽位1-partnum和lockid"></a>partation页：细修槽位1-partnum和lockid</h5><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="built_in">cd</span> new</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">0x08f0 = 2288</span></span><br><span class="line">if=./partationDIR/0x0000011e</span><br><span class="line">of=/opt/data/datachk01</span><br><span class="line">let skip=24</span><br><span class="line">let seek=2288*2*1024+24</span><br><span class="line">let bs=1</span><br><span class="line">let count=4</span><br><span class="line">dd1 $if $of $skip $seek $bs $count 1 1</span><br><span class="line"></span><br><span class="line">if=./partationDIR/0x0000011e</span><br><span class="line">of=/opt/data/datachk01</span><br><span class="line">let skip=24</span><br><span class="line">let seek=2288*2*1024+24+52</span><br><span class="line">let bs=1</span><br><span class="line">let count=4</span><br><span class="line">dd1 $if $of $skip $seek $bs $count 1 1</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"> 244: Could not <span class="keyword">do</span> a physical-order <span class="built_in">read</span> to fetch next row.</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"> 105: ISAM error:  bad isam file format.</span></span><br></pre></td></tr></table></figure>





<h4 id="手术台上的操作：修改bitmap页"><a href="#手术台上的操作：修改bitmap页" class="headerlink" title="手术台上的操作：修改bitmap页"></a>手术台上的操作：修改bitmap页</h4><h5 id="bitmap页：对比"><a href="#bitmap页：对比" class="headerlink" title="bitmap页：对比"></a>bitmap页：对比</h5><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="built_in">cd</span> new</span></span><br><span class="line">mkdir -p diffDir</span><br><span class="line">xxd ../datapageDIR/db01:t6_599 &gt; diffDir/old.bitmap</span><br><span class="line">xxd ./datapageDIR/db01:t6_583  &gt; diffDir/new.bitmap</span><br><span class="line">diff diffDir/old.bitmap diffDir/new.bitmap</span><br></pre></td></tr></table></figure>

<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">[gbasedbt@wei07 new]$ diff diffDir/old.bitmap diffDir/new.bitmap</span><br><span class="line">1,2c1,2</span><br><span class="line">&lt; 0000000: b812 0000 0800 bae4 0038 0408 1800 e43f  .........8.....?</span><br><span class="line">&lt; 0000010: 0000 0000 0000 0000 0100 0000 0200 0000  ................</span><br><span class="line">---</span><br><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash">0000000: 3812 0000 0800 4ace 0038 0408 1800 e43f  8.....J..8.....?</span></span><br><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash">0000010: 0000 0000 0000 0000 0100 0000 0000 0000  ................</span></span><br><span class="line">1024c1024</span><br><span class="line">&lt; 0003ff0: 0000 0000 0000 0000 0000 0000 08f6 0200  ................</span><br><span class="line">---</span><br><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash">0003ff0: 0000 0000 0000 0000 0000 0000 78dc 0200  ............x...</span></span><br><span class="line">[gbasedbt@wei07 new]$</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h5 id="bitmap页：修改0x0000010"><a href="#bitmap页：修改0x0000010" class="headerlink" title="bitmap页：修改0x0000010"></a>bitmap页：修改0x0000010</h5><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">按字节修改</span></span><br><span class="line">let seed=583*16*1024+24</span><br><span class="line">dd1 ../datapageDIR/db01:t6_599 /opt/data/datachk01 24 $seed 1 8 1 1</span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">修改完成后导入一份对比一下</span></span><br><span class="line">dd1 /opt/data/datachk01 tmp 9328 0 1024 16 1 1</span><br><span class="line">xxd tmp  &gt; diffDir/new.bitmap_1</span><br><span class="line">diff diffDir/old.bitmap diffDir/new.bitmap_1</span><br></pre></td></tr></table></figure>

<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line">[gbasedbt@wei07 new]$ diff diffDir/old.bitmap diffDir/new.bitmap_1</span><br><span class="line">1c1</span><br><span class="line">&lt; 0000000: b812 0000 0800 bae4 0038 0408 1800 e43f  .........8.....?</span><br><span class="line">---</span><br><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash">0000000: 3812 0000 0800 4ace 0038 0408 1800 e43f  8.....J..8.....?</span></span><br><span class="line">1024c1024</span><br><span class="line">&lt; 0003ff0: 0000 0000 0000 0000 0000 0000 08f6 0200  ................</span><br><span class="line">---</span><br><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash">0003ff0: 0000 0000 0000 0000 0000 0000 78dc 0200  ............x...</span></span><br><span class="line">[gbasedbt@wei07 new]$ dbaccess db01 &lt;&lt;!</span><br><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash"><span class="keyword">select</span> * from t6;</span></span><br><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash">!</span></span><br><span class="line">Database selected.</span><br><span class="line">         id name                 addr</span><br><span class="line">No rows found.</span><br><span class="line">Database closed.</span><br><span class="line">[gbasedbt@wei07 new]$ oncheck -pp 8388679 0</span><br><span class="line">addr             stamp    chksum nslots flag type         frptr frcnt next     prev</span><br><span class="line">8:4664           187512   ce4a   0      804  FREE         24    16356 0        0</span><br><span class="line">   0:8 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</span><br><span class="line"></span><br><span class="line">[gbasedbt@wei07 new]$</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h4 id="手术台上的操作：修改data页"><a href="#手术台上的操作：修改data页" class="headerlink" title="手术台上的操作：修改data页"></a>手术台上的操作：修改data页</h4><h5 id="data页：对比"><a href="#data页：对比" class="headerlink" title="data页：对比"></a>data页：对比</h5><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="built_in">cd</span> new</span></span><br><span class="line">mkdir -p diffDir</span><br><span class="line">xxd ../datapageDIR/db01:t6_600 &gt; diffDir/old.data</span><br><span class="line">xxd ./datapageDIR/db01:t6_584  &gt; diffDir/new.data</span><br><span class="line">diff diffDir/old.data diffDir/new.data</span><br></pre></td></tr></table></figure>

<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br></pre></td><td class="code"><pre><span class="line">[gbasedbt@wei07 new]$ diff diffDir/old.data diffDir/new.data</span><br><span class="line">1,16c1,16</span><br><span class="line">&lt; 0000000: c012 0000 0800 fce4 0a38 0108 f400 e03e  .........8.....&gt;</span><br><span class="line">&lt; 0000010: 0000 0000 0000 0000 0000 0001 0006 6162  ..............ab</span><br><span class="line">&lt; 0000020: 6364 6566 6162 6364 6566 3120 2020 0000  cdefabcdef1   ..</span><br><span class="line">&lt; 0000030: 0002 0006 6162 6364 6566 6162 6364 6566  ....abcdefabcdef</span><br><span class="line">&lt; 0000040: 3220 2020 0000 0003 0006 6162 6364 6566  2   ......abcdef</span><br><span class="line">&lt; 0000050: 6162 6364 6566 3320 2020 0000 0004 0006  abcdef3   ......</span><br><span class="line">&lt; 0000060: 6162 6364 6566 6162 6364 6566 3420 2020  abcdefabcdef4</span><br><span class="line">&lt; 0000070: 0000 0005 0006 6162 6364 6566 6162 6364  ......abcdefabcd</span><br><span class="line">&lt; 0000080: 6566 3520 2020 0000 0006 0006 6162 6364  ef5   ......abcd</span><br><span class="line">&lt; 0000090: 6566 6162 6364 6566 3620 2020 0000 0007  efabcdef6   ....</span><br><span class="line">&lt; 00000a0: 0006 6162 6364 6566 6162 6364 6566 3720  ..abcdefabcdef7</span><br><span class="line">&lt; 00000b0: 2020 0000 0008 0006 6162 6364 6566 6162    ......abcdefab</span><br><span class="line">&lt; 00000c0: 6364 6566 3820 2020 0000 0009 0006 6162  cdef8   ......ab</span><br><span class="line">&lt; 00000d0: 6364 6566 6162 6364 6566 3920 2020 0000  cdefabcdef9   ..</span><br><span class="line">&lt; 00000e0: 000a 0006 6162 6364 6566 6162 6364 6566  ....abcdefabcdef</span><br><span class="line">&lt; 00000f0: 3130 2020 0000 0000 0000 0000 0000 0000  10  ............</span><br><span class="line">---</span><br><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash">0000000: 0000 0000 0000 0000 0000 0000 0000 0000  ................</span></span><br><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash">0000010: 0000 0000 0000 0000 0000 0000 0000 0000  ................</span></span><br><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash">0000020: 0000 0000 0000 0000 0000 0000 0000 0000  ................</span></span><br><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash">0000030: 0000 0000 0000 0000 0000 0000 0000 0000  ................</span></span><br><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash">0000040: 0000 0000 0000 0000 0000 0000 0000 0000  ................</span></span><br><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash">0000050: 0000 0000 0000 0000 0000 0000 0000 0000  ................</span></span><br><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash">0000060: 0000 0000 0000 0000 0000 0000 0000 0000  ................</span></span><br><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash">0000070: 0000 0000 0000 0000 0000 0000 0000 0000  ................</span></span><br><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash">0000080: 0000 0000 0000 0000 0000 0000 0000 0000  ................</span></span><br><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash">0000090: 0000 0000 0000 0000 0000 0000 0000 0000  ................</span></span><br><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash">00000a0: 0000 0000 0000 0000 0000 0000 0000 0000  ................</span></span><br><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash">00000b0: 0000 0000 0000 0000 0000 0000 0000 0000  ................</span></span><br><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash">00000c0: 0000 0000 0000 0000 0000 0000 0000 0000  ................</span></span><br><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash">00000d0: 0000 0000 0000 0000 0000 0000 0000 0000  ................</span></span><br><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash">00000e0: 0000 0000 0000 0000 0000 0000 0000 0000  ................</span></span><br><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash">00000f0: 0000 0000 0000 0000 0000 0000 0000 0000  ................</span></span><br><span class="line">1022,1024c1022,1024</span><br><span class="line">&lt; 0003fd0: 0000 0000 de00 1600 c800 1600 b200 1600  ................</span><br><span class="line">&lt; 0003fe0: 9c00 1600 8600 1600 7000 1600 5a00 1600  ........p...Z...</span><br><span class="line">&lt; 0003ff0: 4400 1600 2e00 1600 1800 1600 36f6 0200  D...........6...</span><br><span class="line">---</span><br><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash">0003fd0: 0000 0000 0000 0000 0000 0000 0000 0000  ................</span></span><br><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash">0003fe0: 0000 0000 0000 0000 0000 0000 0000 0000  ................</span></span><br><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash">0003ff0: 0000 0000 0000 0000 0000 0000 0000 0000  ................</span></span><br><span class="line">[gbasedbt@wei07 new]$</span><br></pre></td></tr></table></figure>

<h5 id="data页：覆盖"><a href="#data页：覆盖" class="headerlink" title="data页：覆盖"></a>data页：覆盖</h5><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">按字节修改</span></span><br><span class="line">let seed=584*16*1024</span><br><span class="line">dd1 ../datapageDIR/db01:t6_600 /opt/data/datachk01 0 $seed 1 16384 1 1</span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">修改完成后导入一份对比一下</span></span><br><span class="line">dd1 /opt/data/datachk01 tmp 9344 0 1024 16 1 1</span><br><span class="line">xxd tmp  &gt; diffDir/new.data_1</span><br><span class="line">diff diffDir/old.data diffDir/new.data_1</span><br></pre></td></tr></table></figure>

<h5 id="data页：此时会遇到页地址pg-addr错误"><a href="#data页：此时会遇到页地址pg-addr错误" class="headerlink" title="data页：此时会遇到页地址pg_addr错误"></a>data页：此时会遇到页地址pg_addr错误</h5><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br></pre></td><td class="code"><pre><span class="line">[gbasedbt@wei07 new]$ oncheck -cD 8388679</span><br><span class="line"></span><br><span class="line">TBLspace data check for db01:gbasedbt.t6</span><br><span class="line"></span><br><span class="line">BAD PAGE 8:4672: pg_addr 8:4800 != bp-&gt;bf_pagenum 8:4672</span><br><span class="line">WARNING: Modifying TBLspace statistics(pn_nrows):  OLD 10  NEW 0</span><br><span class="line">Reset partition data?</span><br><span class="line">[gbasedbt@wei07 new]$ oncheck -pP 8 4672</span><br><span class="line">addr             stamp    chksum nslots flag type         frptr frcnt next     prev</span><br><span class="line">8:4800           194102   e4fc   10     801  DATA         244   16096 0        0</span><br><span class="line">        slot ptr   len   flg</span><br><span class="line">        1    24    22    0</span><br><span class="line">        2    46    22    0</span><br><span class="line">        3    68    22    0</span><br><span class="line">        4    90    22    0</span><br><span class="line">        5    112   22    0</span><br><span class="line">        6    134   22    0</span><br><span class="line">        7    156   22    0</span><br><span class="line">        8    178   22    0</span><br><span class="line">        9    200   22    0</span><br><span class="line">        10   222   22    0</span><br><span class="line">slot   1:</span><br><span class="line">    0:  0  0  0  1  0  6 61 62 63 64 65 66 61 62 63 64   ......abcdefabcd</span><br><span class="line">   16: 65 66 31 20 20 20                                 ef1   ..........</span><br><span class="line">slot   2:</span><br><span class="line">    0:  0  0  0  2  0  6 61 62 63 64 65 66 61 62 63 64   ......abcdefabcd</span><br><span class="line">   16: 65 66 32 20 20 20                                 ef2   ..........</span><br><span class="line">slot   3:</span><br><span class="line">    0:  0  0  0  3  0  6 61 62 63 64 65 66 61 62 63 64   ......abcdefabcd</span><br><span class="line">   16: 65 66 33 20 20 20                                 ef3   ..........</span><br><span class="line">slot   4:</span><br><span class="line">    0:  0  0  0  4  0  6 61 62 63 64 65 66 61 62 63 64   ......abcdefabcd</span><br><span class="line">   16: 65 66 34 20 20 20                                 ef4   ..........</span><br><span class="line">slot   5:</span><br><span class="line">    0:  0  0  0  5  0  6 61 62 63 64 65 66 61 62 63 64   ......abcdefabcd</span><br><span class="line">   16: 65 66 35 20 20 20                                 ef5   ..........</span><br><span class="line">slot   6:</span><br><span class="line">    0:  0  0  0  6  0  6 61 62 63 64 65 66 61 62 63 64   ......abcdefabcd</span><br><span class="line">   16: 65 66 36 20 20 20                                 ef6   ..........</span><br><span class="line">slot   7:</span><br><span class="line">    0:  0  0  0  7  0  6 61 62 63 64 65 66 61 62 63 64   ......abcdefabcd</span><br><span class="line">   16: 65 66 37 20 20 20                                 ef7   ..........</span><br><span class="line">slot   8:</span><br><span class="line">    0:  0  0  0  8  0  6 61 62 63 64 65 66 61 62 63 64   ......abcdefabcd</span><br><span class="line">   16: 65 66 38 20 20 20                                 ef8   ..........</span><br><span class="line">slot   9:</span><br><span class="line">    0:  0  0  0  9  0  6 61 62 63 64 65 66 61 62 63 64   ......abcdefabcd</span><br><span class="line">   16: 65 66 39 20 20 20                                 ef9   ..........</span><br><span class="line">slot  10:</span><br><span class="line">    0:  0  0  0  a  0  6 61 62 63 64 65 66 61 62 63 64   ......abcdefabcd</span><br><span class="line">   16: 65 66 31 30 20 20                                 ef10  ..........</span><br><span class="line">[gbasedbt@wei07 new]$</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h5 id="data页：细修-页地址"><a href="#data页：细修-页地址" class="headerlink" title="data页：细修-页地址"></a>data页：细修-页地址</h5><figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;stdio.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;stdlib.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;string.h&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="keyword">typedef</span> <span class="class"><span class="keyword">struct</span> <span class="title">Addr</span>&#123;</span></span><br><span class="line">    <span class="type">int</span> page2k;</span><br><span class="line">&#125; ADDR;</span><br><span class="line"></span><br><span class="line"><span class="comment">//页地址等于上一页的地址+8  :addr=4664+8</span></span><br><span class="line"><span class="type">void</span> <span class="title function_">main</span><span class="params">(<span class="type">void</span>)</span>&#123;</span><br><span class="line">    <span class="type">int</span> i=<span class="number">4664</span>;</span><br><span class="line">    i+=<span class="number">8</span>;</span><br><span class="line">    ADDR addr;</span><br><span class="line">    addr.page2k=i;</span><br><span class="line">    FILE *fp;</span><br><span class="line">    fp = fopen(<span class="string">&quot;tmp.addr&quot;</span>,<span class="string">&quot;wb&quot;</span>);</span><br><span class="line">    fwrite(&amp;addr,<span class="keyword">sizeof</span>(ADDR),<span class="number">1</span>,fp);</span><br><span class="line">    fclose(fp);</span><br><span class="line">&#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="built_in">cd</span> new</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">修复address</span></span><br><span class="line">let seed=584*16*1024</span><br><span class="line">dd1 ../tmp.addr /opt/data/datachk01 0 $seed 1 4 1 1</span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">验证</span></span><br><span class="line">dd1 /opt/data/datachk01 tmp $seed 0 1 16384 1 1</span><br><span class="line">xxd tmp</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h5 id="data页：此时会遇到CHECKSUM错误"><a href="#data页：此时会遇到CHECKSUM错误" class="headerlink" title="data页：此时会遇到CHECKSUM错误"></a>data页：此时会遇到CHECKSUM错误</h5><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">[gbasedbt@wei07 new]$ oncheck -cD 8388679</span><br><span class="line"></span><br><span class="line">TBLspace data check for db01:gbasedbt.t6</span><br><span class="line"></span><br><span class="line">BAD PAGE 8:4672: pg_chksum 0xe4fc != PG_CHECKSUM 0xe47c</span><br><span class="line">[gbasedbt@wei07 new]$</span><br><span class="line">[gbasedbt@wei07 new]$ xxd tmp |grep fce4</span><br><span class="line">0000000: 4012 0000 0800 fce4 0a38 0108 f400 e03e  @........8.....&gt;</span><br><span class="line">[gbasedbt@wei07 new]$   fce4 </span><br><span class="line"></span><br></pre></td></tr></table></figure>

<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;stdio.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;stdlib.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;string.h&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="keyword">typedef</span> <span class="class"><span class="keyword">struct</span> <span class="title">Addr</span>&#123;</span></span><br><span class="line">    <span class="type">short</span> page2k;</span><br><span class="line">&#125; ADDR;</span><br><span class="line"></span><br><span class="line"><span class="comment">//页地址等于上一页的地址+8  :addr=4664+8</span></span><br><span class="line"><span class="type">void</span> <span class="title function_">main</span><span class="params">(<span class="type">void</span>)</span>&#123;</span><br><span class="line">    <span class="type">int</span> i=<span class="number">0xe47c</span>;</span><br><span class="line">    ADDR addr;</span><br><span class="line">    addr.page2k=i;</span><br><span class="line">    FILE *fp;</span><br><span class="line">    fp = fopen(<span class="string">&quot;tmp.addr&quot;</span>,<span class="string">&quot;wb&quot;</span>);</span><br><span class="line">    fwrite(&amp;addr,<span class="keyword">sizeof</span>(ADDR),<span class="number">1</span>,fp);</span><br><span class="line">    fclose(fp);</span><br><span class="line">&#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="built_in">cd</span> new</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">修复checksum</span></span><br><span class="line">let seed=584*16*1024+6</span><br><span class="line">dd1 ../tmp.addr /opt/data/datachk01 0 $seed 1 2 1 1</span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">验证</span></span><br><span class="line">rm tmp;touch tmp;</span><br><span class="line">let seed=584*16*1024</span><br><span class="line">dd1 /opt/data/datachk01 tmp $seed 0 1 16 1 1</span><br><span class="line">xxd tmp</span><br></pre></td></tr></table></figure>

<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">上面操作的日志记录：</span></span><br><span class="line">[gbasedbt@wei07 new]$ xxd tmp |grep fce4</span><br><span class="line">0000000: 4012 0000 0800 fce4 0a38 0108 f400 e03e  @........8.....&gt;</span><br><span class="line">[gbasedbt@wei07 new]$ let seed=584*16*1024+6</span><br><span class="line">[gbasedbt@wei07 new]$ dd1 ../tmp.addr /opt/data/datachk01 0 $seed 1 2 1 1</span><br><span class="line">if=../tmp.addr of=/opt/data/datachk01 skip=0 seed=9568262 bs=1 count=2 itw=1 otw=1</span><br><span class="line">[gbasedbt@wei07 new]$</span><br><span class="line">[gbasedbt@wei07 new]$ rm tmp;touch tmp;</span><br><span class="line">[gbasedbt@wei07 new]$ dd1 /opt/data/datachk01 tmp $seed 0 1 16 1 1</span><br><span class="line">if=/opt/data/datachk01 of=tmp skip=9568262 seed=0 bs=1 count=16 itw=1 otw=1</span><br><span class="line">[gbasedbt@wei07 new]$ xxd tmp</span><br><span class="line">0000000: 7ce4 0a38 0108 f400 e03e 0000 0000 0000  |..8.....&gt;......</span><br><span class="line">[gbasedbt@wei07 new]$ rm tmp;touch tmp;</span><br><span class="line">[gbasedbt@wei07 new]$ let seed=584*16*1024</span><br><span class="line">[gbasedbt@wei07 new]$ dd1 /opt/data/datachk01 tmp $seed 0 1 16 1 1</span><br><span class="line">if=/opt/data/datachk01 of=tmp skip=9568256 seed=0 bs=1 count=16 itw=1 otw=1</span><br><span class="line">[gbasedbt@wei07 new]$ xxd tmp</span><br><span class="line">0000000: 4012 0000 0800 7ce4 0a38 0108 f400 e03e  @.....|..8.....&gt;</span><br><span class="line">[gbasedbt@wei07 new]$ oninit -v</span><br><span class="line"></span><br></pre></td></tr></table></figure>



<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">启动数据库，查询OK啦 ^_^</span></span><br><span class="line">[gbasedbt@wei07 new]$ oninit</span><br><span class="line">[gbasedbt@wei07 new]$ dbaccess db01 &lt;&lt;!</span><br><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash"><span class="keyword">select</span> * from t6;</span></span><br><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash">!</span></span><br><span class="line"></span><br><span class="line">Database selected.</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">         id name                 addr</span><br><span class="line"></span><br><span class="line">          1 abcdef               abcdef1</span><br><span class="line">          2 abcdef               abcdef2</span><br><span class="line">          3 abcdef               abcdef3</span><br><span class="line">          4 abcdef               abcdef4</span><br><span class="line">          5 abcdef               abcdef5</span><br><span class="line">          6 abcdef               abcdef6</span><br><span class="line">          7 abcdef               abcdef7</span><br><span class="line">          8 abcdef               abcdef8</span><br><span class="line">          9 abcdef               abcdef9</span><br><span class="line">         10 abcdef               abcdef10</span><br><span class="line"></span><br><span class="line">10 row(s) retrieved.</span><br><span class="line"></span><br><span class="line">Elapsed time: 0.175 sec</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">Database closed.</span><br><span class="line"></span><br><span class="line">[gbasedbt@wei07 new]$</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h4 id="最后一次检查"><a href="#最后一次检查" class="headerlink" title="最后一次检查"></a>最后一次检查</h4><p>此时再做一次oncheck检查，会发现partnum页的pn_nrows页还是0不是10，需要对其修复一下，直接按y修复即可。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">[gbasedbt@wei07 new]$ oncheck -cD 8388679</span><br><span class="line"></span><br><span class="line">TBLspace data check for db01:gbasedbt.t6</span><br><span class="line"></span><br><span class="line">WARNING: Modifying TBLspace statistics(pn_nrows):  OLD 0  NEW 10</span><br><span class="line">Reset partition data? y</span><br><span class="line">[gbasedbt@wei07 new]$</span><br><span class="line">[gbasedbt@wei07 new]$ oncheck -cD 8388679</span><br><span class="line"></span><br><span class="line">TBLspace data check for db01:gbasedbt.t6</span><br><span class="line"></span><br><span class="line">[gbasedbt@wei07 new]$</span><br><span class="line"></span><br></pre></td></tr></table></figure>



<h2 id="导数数据创建新生产"><a href="#导数数据创建新生产" class="headerlink" title="导数数据创建新生产"></a>导数数据创建新生产</h2><pre><code>    略...
</code></pre>
<h2 id="总结："><a href="#总结：" class="headerlink" title="总结："></a>总结：</h2><pre><code>    这里恢复方式是不得已的情况下使用，生产环境请做好数据安全和备份工作。

    实在不能全量备份，最起码请做好下&quot;dbspaces空间规划&quot;和&quot;库表结构&quot;的备份。
</code></pre>
 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/GBase8s/" rel="tag">GBase8s</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/level3/" rel="tag">level3</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E8%87%AA%E7%A0%94/" rel="tag">自研</a></li></ul>

    </footer>
  </div>

   
   
  
</article>

    
  </article>
  

  
  <nav class="page-nav">
    
    <span class="page-number current">1</span><a class="page-number" href="/page/2/">2</a><a class="page-number" href="/page/3/">3</a><span class="space">&hellip;</span><a class="page-number" href="/page/6/">6</a><a class="extend next" rel="next" href="/page/2/">下一页</a>
  </nav>
  
</section>
</div>

      <footer class="footer">
  <div class="outer">
    <ul>
      <li>
        Copyrights &copy;
        2023-2024
        <i class="ri-heart-fill heart_icon"></i> Wang Wei
      </li>
    </ul>
    <ul>
      <li>
        
      </li>
    </ul>
    <ul>
      <li>
        
        
        <span>
  <span><i class="ri-user-3-fill"></i>Visitors:<span id="busuanzi_value_site_uv"></span></span>
  <span class="division">|</span>
  <span><i class="ri-eye-fill"></i>Views:<span id="busuanzi_value_page_pv"></span></span>
</span>
        
      </li>
    </ul>
    <ul>
      
    </ul>
    <ul>
      
    </ul>
    <ul>
      <li>
        <!-- cnzz统计 -->
        
      </li>
    </ul>
  </div>
</footer>    
    </main>
    <div class="float_btns">
      <div class="totop" id="totop">
  <i class="ri-arrow-up-line"></i>
</div>

    </div>
    <aside class="sidebar on">
      <button class="navbar-toggle"></button>
<nav class="navbar">
  
  <div class="logo">
    <a href="/"><img src="/images/ww.ico" alt="朝花夕拾"></a>
  </div>
  
  <ul class="nav nav-main">
    
    <li class="nav-item">
      <a class="nav-item-link" href="/">主页</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/archives">归档</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/categories">分类</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags">标签</a>
    </li>
    
  </ul>
</nav>
<nav class="navbar navbar-bottom">
  <ul class="nav">
    <li class="nav-item">
      
      <a class="nav-item-link nav-item-search"  title="Search">
        <i class="ri-search-line"></i>
      </a>
      
      
    </li>
  </ul>
</nav>
<div class="search-form-wrap">
  <div class="local-search local-search-plugin">
  <input type="search" id="local-search-input" class="local-search-input" placeholder="Search...">
  <div id="local-search-result" class="local-search-result"></div>
</div>
</div>
    </aside>
    <div id="mask"></div>

<!-- #reward -->
<div id="reward">
  <span class="close"><i class="ri-close-line"></i></span>
  <p class="reward-p"><i class="ri-cup-line"></i>请我喝杯咖啡吧~</p>
  <div class="reward-box">
    
    <div class="reward-item">
      <img class="reward-img" src="/images/alipay.jpg">
      <span class="reward-type">支付宝</span>
    </div>
    
    
    <div class="reward-item">
      <img class="reward-img" src="/images/wechat.jpg">
      <span class="reward-type">微信</span>
    </div>
    
  </div>
</div>
    
<script src="/js/jquery-3.6.0.min.js"></script>
 
<script src="/js/lazyload.min.js"></script>

<!-- Tocbot -->

<script src="https://cdn.staticfile.org/jquery-modal/0.9.2/jquery.modal.min.js"></script>
<link
  rel="stylesheet"
  href="https://cdn.staticfile.org/jquery-modal/0.9.2/jquery.modal.min.css"
/>
<script src="https://cdn.staticfile.org/justifiedGallery/3.8.1/js/jquery.justifiedGallery.min.js"></script>

<script src="/dist/main.js"></script>

<!-- ImageViewer -->

<!-- MathJax -->

<!-- Katex -->

<!-- busuanzi  -->
 
<script src="/js/busuanzi-2.3.pure.min.js"></script>
 
<!-- ClickLove -->

<!-- ClickBoom1 -->

<!-- ClickBoom2 -->

<!-- CodeCopy -->
 
<link rel="stylesheet" href="/css/clipboard.css">
 <script src="https://cdn.staticfile.org/clipboard.js/2.0.10/clipboard.min.js"></script>
<script>
  function wait(callback, seconds) {
    var timelag = null;
    timelag = window.setTimeout(callback, seconds);
  }
  !function (e, t, a) {
    var initCopyCode = function(){
      var copyHtml = '';
      copyHtml += '<button class="btn-copy" data-clipboard-snippet="">';
      copyHtml += '<i class="ri-file-copy-2-line"></i><span>COPY</span>';
      copyHtml += '</button>';
      $(".highlight .code pre").before(copyHtml);
      $(".article pre code").before(copyHtml);
      var clipboard = new ClipboardJS('.btn-copy', {
        target: function(trigger) {
          return trigger.nextElementSibling;
        }
      });
      clipboard.on('success', function(e) {
        let $btn = $(e.trigger);
        $btn.addClass('copied');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-checkbox-circle-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPIED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-checkbox-circle-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
      clipboard.on('error', function(e) {
        e.clearSelection();
        let $btn = $(e.trigger);
        $btn.addClass('copy-failed');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-time-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPY FAILED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-time-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
    }
    initCopyCode();
  }(window, document);
</script>
 
<!-- CanvasBackground -->

<script>
  if (window.mermaid) {
    mermaid.initialize({ theme: "forest" });
  }
</script>


    
    

  </div>
</body>

</html>